Normalization: 3NF
Third normal form removes the chain: a non-key attribute should not determine another non-key attribute.
In plain English
If A tells you B, and B tells you C, do not store C next to A.
The one idea
Third normal form removes transitive dependencies: every non-key attribute depends on a candidate key and nothing else.
If A determines B and B determines C, storing C next to A repeats C for every A. The repetition is the anomaly.
By the end
- 01Define a transitive dependency.
- 02Test a relation for 3NF.
- 03Decompose a relation into 3NF.
- 04Explain the trade-offs of further normalization.
The rule
A relation is in 3NF if it is in 2NF and no non-key attribute transitively determines another non-key attribute. Equivalently, every functional dependency X → A has X as a superkey or A as a prime attribute. The second wording is the formal test.
A transitive dependency example
Student(student_id, student_name, advisor_id, advisor_name) has student_id → advisor_id and advisor_id → advisor_name. Therefore student_id → advisor_name transitively. advisor_name is a non-key attribute determined by another non-key attribute, so the relation is not in 3NF.
student_id -> advisor_id
advisor_id -> advisor_name
student_id -> advisor_name transitiveDecomposition
Split the transitive dependency into its own relation: Student(student_id, student_name, advisor_id) and Advisor(advisor_id, advisor_name). The foreign key advisor_id preserves the relationship. The decomposition is lossless because the common attribute is a key in one of the relations.
Student(student_id, student_name, advisor_id)
Advisor(advisor_id, advisor_name)Trade-offs
3NF reduces redundancy and update anomalies, but it can increase the number of joins. Sometimes a controlled denormalization is justified for read-heavy workloads. Make that choice deliberately, with measurements, not by accident.
Student, advisor, and advisor name
Student(student_id, student_name, advisor_id, advisor_name) has key student_id.
Identify the dependencies.
student_id → advisor_id and advisor_id → advisor_name.
Compose them.
student_id → advisor_name is transitive, so advisor_name is not directly dependent on the key.
Move advisor_name to Advisor(advisor_id, advisor_name).
Student keeps advisor_id as a foreign key; the advisor name appears once.
Conclusion3NF does not forbid foreign keys. It forbids a non-key attribute from depending on another non-key attribute.
Instrument
Watch it happen.
Step through one operation at a time
Start with the 3NF target table
The table violates 3NF: no transitive dependency.
| student_id | student_name | advisor_id | advisor_name |
|---|---|---|---|
| 1 | Ada | A1 | Dr. Hopper |
| 2 | Grace | A1 | Dr. Hopper |
| 3 | Linus | A2 | Dr. Turing |
The trade-off
No free correctness.
Gain
Updates touch one advisor row, not every student.
Cost
Reading a student with an advisor name requires a join.
Verdict
Target 3NF for transactional schemas; use BCNF when overlapping candidate keys cause remaining anomalies.
Recap
What to keep.
Takeaways
- +3NF removes transitive dependencies among non-key attributes.
- +The formal test: every determinant is a superkey or the dependent is prime.
- +Decompose the transitive dependency into its own relation.
- +Lossless decomposition requires a common key.
- +Denormalize only with a measured reason.
Traps
- !Confusing 3NF with 2NF.
- !Decomposing without preserving the relationship.
- !Denormalizing before measuring the read workload.
Focus
- →Identify a transitive dependency.
- →Apply the formal 3NF test.
- →Decompose and verify a lossless join.
Check yourself
Before you turn the page.
What does 3NF remove?
Which decomposition is lossless?