Lesson 36: Third Normal Form (3NF)
3NF is the most commonly desired level of normalization for transactional databases. A table in 3NF is in 2NF and meets one additional criterion.
Rule for 3NF
No non-key attribute is transitively dependent on the Primary Key.
- Transitive Dependency: This occurs when a non-key attribute determines another non-key attribute.
PK -> NonKeyAttribute1andNonKeyAttribute1 -> NonKeyAttribute2
Violation Example: Employee Location Data
Assume PK: EmployeeID.
| EmployeeID (PK) | EmployeeName | DeptID | DeptName | DeptManager |
|---|---|---|---|---|
| 101 | Alice | D01 | Sales | John |
| 102 | Bob | D01 | Sales | John |
EmployeeID -> DeptID(Normal dependence)DeptID -> DeptName(Transitive dependence, asDeptNameis dependent on the non-key attributeDeptID).
If we change the name of Department D01, we must update multiple employee records (Update Anomaly).
Correction (Achieving 3NF)
We separate the transitively dependent attributes (DeptName, DeptManager) into a new table (Departments).
EmployeesTable: PK:EmployeeID. Contains FK:DeptID.DepartmentsTable: PK:DeptID. ContainsDeptName,DeptManager.
Now, data about the Department only appears once, and the dependency is direct and managed via the Foreign Key.