Third Normal Form (3NF) - Detailed Explanation
Third Normal Form (3NF)
Third Normal Form (3NF) is a database normalization rule that removes transitive dependencies from a relation. It ensures that non-key attributes depend only on the primary key and nothing else.
1. What is a Transitive Dependency?
A transitive dependency occurs when:
-
X → Z
-
Z → Y
So indirectly:
-
X → Y through Z
But Z is not a candidate key.
This means Y depends on X indirectly through Z, which causes redundancy and possible update anomalies.
2. Definition of 3NF
According to Edgar F. Codd’s definition:
A relation schema R is in Third Normal Form (3NF) if:
It is already in Second Normal Form (2NF), and
No non-prime attribute is transitively dependent on the primary key.
Important Terms
-
Prime attribute → part of a candidate key
-
Non-prime attribute → not part of any candidate key
So in simple terms:
Non-key attributes should depend directly on the primary key, not through another non-key attribute.
3. Example
Relation: EMP_DEPT
| Ssn | Dnumber | Dname | Dmgr_ssn |
|---|
Functional Dependencies
-
Ssn → Dnumber
-
Dnumber → Dmgr_ssn
-
Dnumber → Dname
So we get a transitive dependency:
Here:
-
Ssn = Primary Key
-
Dnumber = Non-key attribute
-
Dmgr_ssn, Dname depend on Dnumber, not directly on Ssn
Therefore:
This violates 3NF.
4. Problem with Transitive Dependency
If the table is kept as it is:
-
Data redundancy occurs
-
Update anomalies occur
-
Department information repeats for many employees
Example:
| Ssn | Dnumber | Dname |
|---|---|---|
| E1 | D1 | Sales |
| E2 | D1 | Sales |
If Sales changes to Marketing, we must update many rows.
5. Converting to 3NF (Decomposition)
The solution is splitting the table into two relations.
Table 1: ED1 (Employee)
| Ssn | Dnumber |
|---|
Dependency:
Table 2: ED2 (Department)
| Dnumber | Dname | Dmgr_ssn |
|---|
Dependencies:
Now:
-
Each table represents independent facts
-
No transitive dependencies exist
6. Recovering Original Table
Using NATURAL JOIN:
We can reconstruct the original EMP_DEPT table without spurious tuples.
Fig:Normalizing EMP_DEPT table into 3NF Relations
7. Intuitive Understanding of 3NF
3NF removes two problematic dependencies:
-
Partial dependency → handled by 2NF
-
Transitive dependency → handled by 3NF
Rule of thumb:
Non-key attributes must depend only on the key, the whole key, and nothing but the key.
8. Quick Summary
✅ 3NF Goal:
Ensure that every non-key attribute depends only on the primary key and not on other non-key attributes.
| Normal Form | Rule | Problem Removed |
|---|---|---|
| 1NF | Atomic attributes | Repeating groups |
| 2NF | No partial dependency on key | Partial dependency |
| 3NF | No transitive dependency | Indirect dependency |
Examples
Problem 1
Relation
Functional Dependencies
Step 1: Primary Key
Step 2: Transitive Dependency
So:
Step 3: Decomposition into 3NF
Table 1
Table 2
Problem 2
Relation
Functional Dependencies
Primary Key
Transitive Dependency
3NF Decomposition
EMPLOYEE
DEPARTMENT
Problem 3
Relation
Functional Dependencies
Primary Key
Transitive Dependency
3NF Decomposition
BOOK
AUTHOR
Problem 4
Relation
Functional Dependencies
Primary Key
Transitive Dependency
3NF Decomposition
ORDER
CUSTOMER
Problem 5
Relation
Functional Dependencies
Candidate Key
Transitive Dependencies
3NF Decomposition
STUDENT
COURSE
REGISTRATION

Comments
Post a Comment