Third Normal Form (3NF)

Rules of 3NF

  • The table is in 2NF.
  • No transitive dependency: non-key columns depend only on the key, not on other non-key columns.

A well-known summary: every non-key column must depend on "the key, the whole key, and nothing but the key".

Example

Not in 3NF: DeptName depends on DeptID, which depends on EmployeeID.

EmployeeIDNameDeptIDDeptName
1Rahul10Sales
2Sara10Sales
4Ananya20Support

In 3NF:

EmployeeIDNameDeptID
1Rahul10
2Sara10
4Ananya20
DeptIDDeptName
10Sales
20Support

Putting It Back Together

Example

Normalized tables are recombined with a join whenever needed:

CREATE TABLE Departments (DeptID INT PRIMARY KEY, DeptName VARCHAR(50));
CREATE TABLE Staff (EmployeeID INT PRIMARY KEY, Name VARCHAR(50), DeptID INT REFERENCES Departments(DeptID));
INSERT INTO Departments VALUES (10, 'Sales'), (20, 'Support');
INSERT INTO Staff VALUES (1, 'Rahul', 10), (2, 'Sara', 10), (4, 'Ananya', 20);

-- rename a department in ONE place
UPDATE Departments SET DeptName = 'Customer Success' WHERE DeptID = 20;

SELECT s.Name, d.DeptName FROM Staff s JOIN Departments d USING (DeptID);

Result: 3 rows

NameDeptName
RahulSales
SaraSales
AnanyaCustomer Success