![SQL Views](https://coderzpy.com/wp-content/uploads/2023/02/unnamed.png)
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_ID | DEPARTMENT | HOBBY |
---|---|---|
E1 | HR | Badminton |
E2 | Sales | Reading |
E1 | HR | Reading |
E1 | Sales | Badminton |
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_ID | DEPARTMENT |
---|---|
E1 | HR |
E2 | Sales |
E1 | HR |
E1 | Sales |
EMPLOYEE_ID | HOBBY |
---|---|
E1 | Badminton |
E2 | Reading |
E1 | Reading |
E1 | Badminton |
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
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Leave a Comment
You must be logged in to post a comment.