coderz.py

Keep Coding Keep Cheering!

Fourth Normal Form (4NF)

SQL Views
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

Leave a Comment

Advertisement