Categories: DBMS

Fourth Normal Form (4NF)

What is 4NF?

A level of database normalisation known as the fourth normal form (4NF) is one in which a candidate key is the only non-trivial multivalued dependency. It advances the Boyce-Codd Normal Form and the first three normal forms (1NF, 2NF, and 3NF) (BCNF). It specifies that a database shall not have more than one multivalued dependency in addition to meeting the BCNF standards.

Rules for 4NF:
  • If a relation has no multi-valued dependencies and is in Boyce Codd normal form, it is said to be in 4NF.
  • If there are multiple values of B for a given value of A in a dependency A → B, the relationship is said to be a multi-valued dependency.
What is Multi-valued Dependency?
  • When two attributes in a table are independent of one another yet both depend on a third attribute, the situation is known as multivalued dependency.
  • It always requires at least three attributes because a multivalued dependence consists of at least two attributes that are dependent on a third attribute.

For instance, the relation R(A, B, C), if A and B have a multi-valued dependency, then B and C should be independent of each other.

Example:

Let’s take a look at the Employee table:

EMPLOYEE_IDDEPARTMENTHOBBY
E1HRBadminton
E2SalesReading
E1HRReading
E1SalesBadminton
Employee Table

In the above table, you can see that for the Employee E901 multiple records exist in the DEPARTMENT and the HOBBY attribute. Hence the multi-valued dependencies are,

EMPLOYEE_ID 
−
>
−> DEPARTMENT
EMPLOYEE_ID 
−
>
−> HOBBY

This table is already in BCNF. We just need to remove the multi-valued dependency therefore, decompose the original table into two tables.

That is,

EMPLOYEE_IDDEPARTMENT
E1HR
E2Sales
E1HR
E1Sales
Emp_Dept Table
EMPLOYEE_IDHOBBY
E1Badminton
E2Reading
E1Reading
E1Badminton
Emp_Hobby Table

Now one can say that these tables are in 4NF as the multi-valued dependency is removed.

Note: also read about Boyce–Codd Normal Form

Follow Me

Please follow me to read my latest post on programming and technology if you like my post.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

Longest Absolute Path in File System Representation

Find the length of the longest absolute path to a file within the abstracted file…

3 days ago

Efficient Order Log Storage

You manage an e-commerce website and need to keep track of the last N order…

2 weeks ago

Select a Random Element from a Stream

You are given a stream of elements that is too large to fit into memory.…

3 weeks ago

Estimate π Using Monte Carlo Method

The formula for the area of a circle is given by πr². Use the Monte…

1 month ago

Longest Substring with K Distinct Characters

Given an integer k and a string s, write a function to determine the length…

1 month ago

Staircase Climbing Ways

There is a staircase with N steps, and you can ascend either 1 step or…

1 month ago