DBMS Notes
A relation R is in Fourth Normal Form (4NF) if, for every non-trivial multivalued dependency X →→ Y in R, the determinant X is a superkey of R. Fourth...
Definition
A relation R is in Fourth Normal Form (4NF) if, for every non-trivial multivalued dependency X →→ Y in R, the determinant X is a superkey of R. Fourth Normal Form builds on BCNF by additionally eliminating problems caused by multivalued dependencies (MVDs).
A relation can be in BCNF (no problematic functional dependencies) yet still contain significant redundancy caused by independent multi-valued facts stored in the same table.
Multivalued Dependency Recap
X →→ Y means: for a given X value, the set of Y values is determined independently of the other attributes (Z = R - X - Y).
Formal definition: In R(X, Y, Z), X →→ Y holds if whenever two tuples t1 and t2 agree on X, there exist tuples t3 and t4 such that:
- t3[X] = t1[X], t3[Y] = t1[Y], t3[Z] = t2[Z]
- t4[X] = t2[X], t4[Y] = t2[Y], t4[Z] = t1[Z]
In practice, this means: if you swap the Y values between any two tuples with the same X, the resulting tuples must also be in the relation.
4NF Decomposition
To convert a relation violating 4NF, decompose it so each MVD resides in its own binary relation:
| E001 | Java | E001 | English | |
|---|---|---|---|---|
| E001 | Python | E001 | Hindi | |
| E002 | SQL | E002 | French |
Before (BCNF but NOT 4NF)
After decomposition
Benefits
4NF Decomposition Algorithm
WHILE there exists a relation R not in 4NF
Find a non-trivial MVD X -->> Y where X is not a superkey of R
Decompose R into
R1 = X U Y (attributes of the MVD)
R2 = R - Y (remaining attributes, keeping X)
Repeat until all relations are in 4NF
Another Example — Teacher Subjects and Hobbies
| TchID | Subject | Hobby |
|---|---|---|
| T1 | DBMS | Painting |
| T1 | DBMS | Chess |
| T1 | OS | Painting |
| T1 | OS | Chess |
Instance
Decompose
When an MVD Does NOT Violate 4NF
If X is a superkey, the MVD is trivially satisfied and does not cause redundancy:
| Relation | CourseTextbook(CourseID, TextbookTitle) |
| Key | (CourseID, TextbookTitle) |
| MVD | CourseID -->> TextbookTitle |
Detecting MVDs
Unlike functional dependencies, MVDs are harder to detect from data alone. You need to understand the business semantics:
| Signal | Likely MVD |
|---|---|
| Two independent lists associated with the same entity | X →→ Y and X →→ Z |
| All combinations must appear for each entity | Independence between Y and Z |
| Adding one fact requires multiple row insertions | Redundancy from MVD |
Comparison: BCNF, 4NF, 5NF
| Normal Form | Eliminates | Key Condition |
|---|---|---|
| BCNF | All FDs where determinant is not superkey | Every FD determinant is a superkey |
| 4NF | All MVDs where determinant is not superkey | Every MVD determinant is a superkey |
| 5NF | All JDs not implied by candidate keys | Every JD implied by CKs |
Lossless Property of 4NF Decomposition
The decomposition using MVD X →→ Y is always lossless:
Summary
- 4NF addresses redundancy from multivalued dependencies that BCNF cannot detect
- An MVD X →→ Y means Y values are determined independently of other attributes given X
- 4NF requires every non-trivial MVD to have a superkey as its determinant
- Decomposition splits independent multi-valued facts into separate tables
- The result is always a lossless decomposition with dramatically less redundancy
Continue the lesson path