Database.3NF, give example

📘 Third Normal Form (3NF)

A table is in 3NF if:

  1. ✅ It is in 2NF
  2. ✅ It has no transitive dependencies — i.e., non-key columns do not depend on other non-key columns

🔍 What is a Transitive Dependency?

A transitive dependency happens when:

A non-key column depends on another non-key column, which in turn depends on the primary key.

In short:
Primary Key → A → B
Then B is transitively dependent on the primary key via A → ❌ violates 3NF.


❌ Example: Not in 3NF

Table: Employees

EmpID (PK)NameDeptIDDeptName
1Alice10HR
2Bob20Finance
3Carol10HR
  • Primary key: EmpID
  • DeptName depends on DeptID
  • DeptID depends on EmpID

So:

  • EmpID → DeptID → DeptName → ❌ transitive dependency
  • This violates 3NF

✅ Convert to 3NF: Remove Transitive Dependency

Table 1: Employees

EmpID (PK)NameDeptID
1Alice10
2Bob20
3Carol10

Table 2: Departments

DeptID (PK)DeptName
10HR
20Finance
  • ✅ Now DeptName depends only on DeptID
  • ✅ No transitive dependency in Employees
  • ✅ The schema is in 3NF

🧠 Summary of Normal Forms:

FormRule
1NFAtomic values, no repeating groups
2NFNo partial dependency on part of composite key
3NFNo transitive dependency (non-key columns shouldn’t depend on each other)
This entry was posted in Без рубрики. Bookmark the permalink.