Careeroza
Why Normalize?
What is Normalization?
Normalization is the process of organising columns and tables so that each fact is stored in exactly one place. It is done in steps called normal forms (1NF, 2NF, 3NF, BCNF...). Each form removes a specific kind of redundancy.
The Problem: Anomalies
Consider one wide table that stores orders together with customer and product details:
| OrderID | CustomerName | CustomerCity | ProductName | Price | Qty |
|---|---|---|---|---|---|
| 101 | Aarav Traders | Mumbai | Basmati Rice 5kg | 12.50 | 10 |
| 101 | Aarav Traders | Mumbai | Green Tea 100 bags | 6.75 | 5 |
| 104 | Aarav Traders | Mumbai | Green Tea 100 bags | 6.75 | 3 |
- Update anomaly: if Aarav Traders moves to Pune, three rows must change; miss one and the data contradicts itself.
- Insert anomaly: you cannot record a new product until somebody orders it.
- Delete anomaly: deleting order 102 might delete the only record that a product or customer ever existed.
Key Terms
| Term | Meaning |
|---|---|
| Functional dependency (A → B) | knowing A determines B. CustomerID → CustomerCity |
| Candidate key | a minimal set of columns that uniquely identifies a row |
| Prime attribute | a column that is part of some candidate key |
| Partial dependency | a non-key column depends on part of a composite key |
| Transitive dependency | a non-key column depends on another non-key column |