Understanding Database Normalization in SQL with Example
See how raw, repetitive data gets organized into clean, related tables.
Normalization is the process of structuring a database to reduce redundancy and prevent data inconsistencies. Rather than explaining it in the abstract, it's easiest to understand through an example table that gets progressively cleaned up.
The Unnormalized Starting Point
OrderID | Customer | Product1 | Product2 1 | Riya | Pen | Notebook 2 | Aman | Pen | NULL
Storing multiple products in separate columns makes it hard to add a third product, and wastes space with NULLs.
First Normal Form (1NF)
Eliminate repeating groups — each row should hold a single value per column.
OrderID | Customer | Product 1 | Riya | Pen 1 | Riya | Notebook 2 | Aman | Pen
Second Normal Form (2NF)
Remove partial dependency — every non-key column must depend on the whole primary key, not just part of it. This usually means splitting into separate Orders and OrderItems tables.
Orders: OrderID, Customer OrderItems: OrderID, Product
Third Normal Form (3NF)
Remove transitive dependency — non-key columns shouldn't depend on other non-key columns. If Customer also stored a CustomerCity, that belongs in its own Customers table instead.
Customers: CustomerID, Name, City Orders: OrderID, CustomerID OrderItems: OrderID, Product
Why Normalize?
- Prevents the same fact from being stored (and potentially updated inconsistently) in multiple places
- Makes updates and deletes safer and more predictable
- Keeps tables focused on a single, clear responsibility