4NF, 5NF, Multivalued and Join Dependencies
Fourth normal form removes independent multivalued facts stored in one relation. Fifth normal form removes join dependencies, where a relation can be split three ways but not two.
-
DBMS Fundamentals
- Data, Information and Databases
- What a DBMS Is and Why It Exists
- File System versus DBMS
- Advantages and Limitations of a DBMS
- Database Users and the Role of the DBA
- Three Level Architecture and Data Abstraction
- Logical and Physical Data Independence
- Schema, Instance and Metadata
- Database Applications and the Database System Environment
- Database Architecture
- Data Models
-
ER Model
- Entities, Entity Sets and Entity Types
- Types of Attributes in the ER Model
- Keys in the ER Model
- Relationships, Relationship Sets and Degree
- Cardinality and Participation Constraints
- Strong and Weak Entities
- Drawing and Reading ER Diagrams
- Extended ER: Generalisation, Specialisation and Aggregation
- Converting an ER Diagram into Relational Tables
- ER Design Projects
- Relational Model
- Relational Algebra
- Functional Dependencies
-
Normalisation
- Why Normalisation Exists: Anomalies and Redundancy
- First Normal Form
- Second Normal Form and Partial Dependency
- Third Normal Form and Transitive Dependency
- BCNF and BCNF Decomposition
- 4NF, 5NF, Multivalued and Join Dependencies
- Lossless Decomposition and Dependency Preservation
- Complete Worked Normalisation: Unnormalised to BCNF
- Denormalisation and When to Use It
Concept
BCNF removes every redundancy caused by functional dependencies. Two further kinds of dependency can still cause redundancy, and 4NF and 5NF address them.
Multivalued dependency
A multivalued dependency X ->> Y holds when, for each value of X, there is a set of Y values that is independent of the other attributes of the relation.
STUDENT_INFO ( roll, course, hobby )
roll | course | hobby
-----+--------+---------
21 | CS201 | Chess
21 | CS201 | Music
21 | CS202 | Chess
21 | CS202 | Music
Meera takes 2 courses and has 2 hobbies. Her courses have
NOTHING to do with her hobbies. Yet the relation is forced
to store 2 x 2 = 4 rows to avoid implying a connection.
Add one more hobby and you must add 2 more rows, one per
course, or the relation falsely suggests that the new hobby
applies to only some courses.
roll ->> course
roll ->> hobby
Note: every functional dependency is also a multivalued
dependency, with a set of size one. MVDs generalise FDs.Fourth normal form
A relation is in 4NF when it is in BCNF and, for every non trivial multivalued dependency X ->> Y, X is a super key.
STUDENT_INFO is in BCNF - the only key is the whole
relation, and there are no functional dependencies to
violate anything.
But roll ->> course and roll is not a super key,
so it is NOT in 4NF.
DECOMPOSE into one relation per independent fact:
STUDENT_COURSE ( roll, course ) STUDENT_HOBBY ( roll, hobby )
21 CS201 21 Chess
21 CS202 21 Music
4 rows become 4 rows here, but the growth changes:
3 courses and 4 hobbies
combined: 12 rows
split: 3 + 4 = 7 rows
and adding a hobby now adds exactly ONE row.
RULE: a multivalued dependency is trivial - and therefore
harmless - when Y is a subset of X, or when X and Y
together are the whole relation. That is why a relation
with only TWO attributes is always in 4NF.Join dependency and fifth normal form
A join dependency holds when a relation can be reconstructed by joining several of its projections, but not by joining any two of them. 5NF, also called project join normal form, removes them.
SUPPLY ( supplier, part, project )
meaning: this supplier supplies this part to this project
Business rule that creates the join dependency:
IF a supplier supplies a part (anywhere)
AND that part is used by a project
AND that supplier supplies that project (any part)
THEN that supplier supplies that part to that project
supplier | part | project
---------+-------+--------
S1 | Bolt | P1
S1 | Nut | P2
S2 | Bolt | P2
Apply the rule to the three rows:
S1 supplies Bolt (row 1)
Bolt is used by P2 (row 3)
S1 supplies to P2 (row 2)
-> therefore S1 supplies Bolt to P2 MUST also be true
So the row S1 | Bolt | P2 is IMPLIED, not independent.
The relation contains a redundancy that no functional or
multivalued dependency describes. DECOMPOSE INTO THREE
SP ( supplier, part ) PJ ( part, project )
S1 Bolt Bolt P1
S1 Nut Nut P2
S2 Bolt Bolt P2
SJ ( supplier, project )
S1 P1
S1 P2
S2 P2
Joining ALL THREE reconstructs the original exactly.
Joining any TWO produces spurious rows.
That is the signature of 5NF: it is decomposable into
three or more relations, but not into two.The full ladder
| Form | Removes | Based on | Met in practice? |
|---|---|---|---|
| 1NF | Repeating groups | Atomicity | Always |
| 2NF | Partial dependency | Functional | Always |
| 3NF | Transitive dependency | Functional | Usual target |
| BCNF | Non key determinants | Functional | Common target |
| 4NF | Independent multivalued facts | Multivalued | Occasionally needed |
| 5NF | Join dependency | Join | Rare |
| 6NF / DKNF | Remaining anomalies | Temporal / all constraints | Specialist |
In practice a design that reaches BCNF is almost always in 4NF and 5NF already. The two higher forms are examined far more often than they are needed — but the 4NF case, an entity with two independent multivalued attributes, does occur and is worth recognising.
Spotting a 4NF violation in real design
Warning sign: one relation storing two lists that have
nothing to do with each other.
EMPLOYEE_INFO ( emp_id, skill, language )
DOCTOR_INFO ( doctor, specialisation, clinic_day )
PRODUCT_INFO ( product, colour, size )
Ask: does choosing one value of A constrain the choice of
B in any way?
NO -> they are independent, split them
YES -> they belong together, keep them
A shirt available in red only in large IS a real
constraint, so ( product, colour, size ) may be correct.
A doctor whose specialisation has nothing to do with which
days they attend is NOT, so split it.Common mistakes
- Splitting attributes that are not independent. If the combination carries meaning, splitting loses information.
- Thinking a two attribute relation can violate 4NF. It cannot; every MVD in it is trivial.
- Confusing a multivalued dependency with a multivalued attribute. The attribute problem is 1NF; the dependency problem is 4NF.
- Decomposing a 5NF violation into two relations. It needs three or more, by definition.
- Chasing 5NF on ordinary schemas. Confirm the join dependency exists as a real business rule first.
Exam and interview questions
- Define a multivalued dependency and give an example with the row explosion it causes.
- Define 4NF and decompose a violating relation.
- Why is every relation with two attributes automatically in 4NF?
- Define a join dependency and explain the supplier, part, project example.
- Define 5NF and state what distinguishes it from 4NF.
- Why are 4NF and 5NF rarely needed in practice?
Practice
- COURSE_INFO ( course, instructor, textbook ) where instructors and textbooks are independent. Test 4NF and decompose.
- A student has multiple phone numbers and multiple email addresses. Design it in 4NF.
- Explain why ( product, colour, size ) might legitimately stay as one relation.
- Verify by hand that joining any two of SP, PJ and SJ produces a spurious row.
Conclusion
4NF removes independent multivalued facts crammed into one relation; 5NF removes join dependencies that only a three way split can eliminate. Both are worth recognising, and both are usually already satisfied once a design reaches BCNF.