4NF in DBMS

Learn via video course
FREE
View all courses
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
DBMS Course - Master the Fundamentals and Advanced Concepts
DBMS Course - Master the Fundamentals and Advanced Concepts
by Srikanth Varma
1000
5
Start Learning
Topics Covered

4NF in DBMS stands for Fourth Normal Form and the relation is said to be in 4NF if the relation is in Boyce Codd Normal Form and has no multi-valued dependency.

Multi-valued dependency for a relation A >-> B exists when for a single value of A, multiple values of B exist.
For a relation R(A,B,C,D)R(A, B, C, D), if the relation has A >-> B and A >-> C then, R is decomposed to R1(A,B)R1(A, B) and R2(A,C,D)R2(A, C, D).

Normalization in DBMS

Normalization is the process of reducing redundancy in a relation. Redundancy in relation may result in insertion, deletion, and update errors. As a result, normalization helps in reducing relational redundancy and the normal forms are used to remove these redundancies from a database table.

A relation is said to be in BCNF if the relation's attributes contain only an atomic/single value, all the non-key attributes must be fully functionally dependent on the primary key, there is no transitive dependency for non-key attributes, and for every functional dependency X>->Y, X is the super key of the table. We will understand this better once we go through the examples.

What is Multi-valued Dependency?

If the following requirements are met, a table is said to have a multi-valued dependency,

  • For a single value of A in the dependency A -> B, multiple values of B exist.
  • A table should have at least 3 columns.
  • For the relation R(A,B,C)R(A, B, C), if A and B have a multi-valued dependency, then B and C should be independent of each other.

Let's have an example to understand multi-valued dependency:
The below table shows the details of an office department exchange event having the columns, EMPLOYEE_ID, DEPARTMENT, and HOBBY.

EMPLOYEE_IDDEPARTMENTHOBBY
E901HRBadminton
E901SalesReading
E902MarketingCricket
E903FinanceFootball

As you can see in the above table, Employee E901 is interested in two departments HR and Sales, and, has two hobbies Badminton and Reading. This will result in multiple records for E901 as,

EMPLOYEE_IDDEPARTMENTHOBBY
E901HRBadminton
E901SalesReading
E901HRReading
E901SalesBadminton

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 and
EMPLOYEE_ID >-> HOBBY
Also, the DEPARTMENT and HOBBY attributes are independent of each other thus leading to a multi-valued dependency in the above table.

Join Dependency

Join Dependency is similar to Multi-Valued Dependency as Join Dependency is also a constraint.

Let R be a relation schema and the decompositions of R are R1,R2,R3,...,RnR1, R2, R3,..., Rn. R is said to be in Join Dependency if and only if every instance of R, r is equal to the join of its projections on R1,R2,R3,...,RnR1, R2, R3,..., Rn.

You can read more about Join Dependency here at Join Dependency in DBMS.

Examples of 4NF

Let's have a look over some tables and check whether these are in 4NF or not.

TEACHERSUBJECTSTUDENT
Amit KDBMSManish
VaibhavOSManish
Amit KDBMSRaman
AnuragOSRaman

Candidate keys are (TEACHER, STUDENT) and (SUBJECT, STUDENT).

The above table is not in 4NF as the table doesn't satisfy the condition for BCNF. If we try to delete the student Raman from the table we will not be able to determine that Anurag teaches OS. Hence TEACHER attribute must also be a key to satisfy the condition for BCNF.

Let's have another example where a table is used to store the Roll Numbers and Names of the students enrolled in a university.

ROLL_NOSTUDENT
901Armaan
902Ashutosh
903Baljeet
904Bhupinder

Let's check for BCNF first:

The Candidate key is ROLL_NO, and the prime attribute is also ROLL_NO
The above table has a single value for each attribute, the non-key attribute STUDENT is fully dependent on the primary key, and there is no transitive dependency for the non-key attribute STUDENT, and for ROLL_NO >-> STUDENT, ROLL_NO is the super key of the table. Therefore the above table is in BCNF.

Now let's check for Multi-Valued Dependency:

Since there are only two columns there is not any multi-valued dependency in the above table hence the above table is in 4NF.

Rules for 4NF

A table is said to be in 4NF if the following conditions are met,

How to Satisfy 4NF ?

Let's see how we can satisfy the conditions of 4NF in DBMS by looking at the example we used in Multi-Valued Dependency

EMPLOYEE_IDDEPARTMENTHOBBY
E901HRBadminton
E901SalesReading
E902MarketingCricket
E903FinanceFootball

The multi-valued dependencies in the above table are,

EMPLOYEE_ID >-> DEPARTMENT and
EMPLOYEE_ID >-> HOBBY

To satisfy the fourth normal form, we can decompose the relation into two tables,

EMPLOYEE_IDDEPARTMENT
E901HR
E901Sales
E902Marketing
E903Finance

and,

EMPLOYEE_IDHOBBY
E901Badminton
E901Reading
E902Cricket
E903Football

Now the above relation is in 4NF.

So if R(A,B,C,D)R(A, B, C, D) has A >-> B and A >-> C then, R is decomposed to R1(A,B)R1(A, B) and R2(A,C,D)R2(A, C, D).

In addition to multi-valued dependency, a table can have functional dependency too. In that case, the functionally dependent columns are moved to a different table, while the multi-valued dependent columns are moved to other tables.

Conclusion

  • Normalization is the process of reducing redundancy in a relation. A relation is said to be in 4NF if the relation is in Boyce Codd Normal Form (BCNF) and has no multi-valued dependency.
  • Multi-valued dependency for a relation A >-> B exists when for a single value of A, multiple values of B exist, also the table should have at least 3 columns. If in a relation R(A,B,C)R(A, B, C) A and B have a multi-valued dependency and B and C are independent of each other then the relationship has a multi-valued dependency.
  • For the relation R(A,B,C,D)R(A, B, C, D), if R has A >-> B and A >-> C then, R is decomposed to R1(A,B)R1(A, B) and R2(A,C,D)R2(A, C, D) to eliminate multi-valued dependency.

Read More: