# Fourth Normal Form (4NF) | DBMS

**DBMS 4NF**: In this tutorial, we are going to learn about the **fourth normal form (4NF) in Database Management System**.

Submitted by Anushree Goswami, on August 19, 2019

**Fourth normal form (4NF)** is a normal form used in database normalization, in which there are no non-trivial multivalued dependencies except a candidate key. After Boyce–Codd normal form (BCNF), 4NF is the next level of normalization. Although the second, third, and Boyce–Codd normal forms operate with functional dependencies, 4NF is operated with a more universal type of dependency known as a multivalued dependency.

A table or relation is in 4NF if and only if, for each attribute of its non-trivial multivalued dependencies P→Q, P is a super key—that means, P is either a candidate key or a superset thence.

**Properties:**

A relation R with attributes, its values and tuples is in 4NF if and only if the following conditions are satisfied.

- The relation or table should be in the Boyce-Codd Normal Form (BCNF).
- The relation or table should not have any Multivalued Dependency.

A table which consists of a multivalued dependency breaches the normalization attainment of **Fourth Normal Form (4NF)** because it generates unneeded redundancies and can contribute to incompatible data which will not be inconsistency. To take this forward and up towards 4NF, it is important to divide this data and information into two tables or relations.

**Multivalued Dependency**

Multivalued dependency takes place when there are one or more rows in a table or relation which indicates the existence of one or more other rows in the same table or relation. In another way, if we observe, two attributes (or columns) in a table or relation are not dependent on each other, but both of them depend on a third attribute. A multivalued dependency always needs a minimum of three attributes because it contains at least two attributes that are dependent on a third.

For a Functional dependency in which P holds Q (P -> Q), if for a single value of P, multiple values of Q exists, then the table or relation may have a multi-valued dependency. The table or relation should contain minimally three attributes and Q and S should not be dependent for P ->> Q multivalued dependency.

If the following points are satisfied, then a table or relation has a multivalued dependency,

- In a table, for a Functional Dependency P which holds Q (P → Q), if for a single value of P, multiple value of Q exists, then the table may have multi-valued dependency.
- Also, the condition is that a table should have at-least three columns for it to have a multivalued dependency.
- And, for a relation R(P, Q, S), if there is a multi-valued dependency between P and Q, then Q and S should not be dependent on each other.

**Example:**

Consider a database table which contain student Name, Hobby and subject,

Name | Hobby | Subject |
---|---|---|

Arvind | Cricket | Maths |

Sameer | Football | Science |

Rajeev | Chess | Social science |

Simran | Badminton | English |

Rajat | Singing | Hindi |

In the above table, there is no connection between the columns of Hobby and Subject. They are both independent of each other.

So there is a multivalued dependency, which assists towards unneeded repetition and redundancy of data and other anomalies as well.

To make the above relation satisfy with the **fourth normal form** condition and its properties, we can divide the table into two tables, which contain Name and Subject in one table and Name and Hobby in another table.

Name | Hobby |
---|---|

Arvind | Cricket |

Sameer | Football |

Rajeev | Chess |

Simran | Badminton |

Rajat | Singing |

Name | Subject |
---|---|

Arvind | Maths |

Sameer | Science |

Rajeev | Social science |

Simran | English |

Rajat | Hindi |

Now, this relation satisfied the conditions of the fourth normal form.

A table can also contain a functional dependency along with multi-valued dependency. In that case, the functionally dependent columns are transferred in a separate table and the multi-valued dependent columns are transferred to separate tables.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions