Overview

Normalization organises tables so each fact is stored once, which prevents update, insert and delete anomalies. It is driven by functional dependencies: column set determines column set when equal values always imply equal values, written .

Core concepts

FormRule (informal)
1NFAtomic values, no repeating groups, every row identifiable
2NF1NF and no non-key column depends on part of a composite key
3NF2NF and no non-key column depends on another non-key column (no transitive dependency)
BCNFEvery determinant is a candidate key

Rule of thumb: every non-key attribute depends on the key, the whole key, and nothing but the key.

Worked example

A flat table order_lines(order_id, product_id, product_name, customer_name, qty) repeats product_name on every line (partial dependency on product_id) and customer_name on every line of an order. Renaming a product requires updating many rows, and an order with a typo in the customer name is inconsistent. Split into:

customers(id PK, name)
products(id PK, name)
orders(id PK, customer_id FK)
order_lines(order_id FK, product_id FK, qty, PRIMARY KEY (order_id, product_id))

Pitfalls and production notes

  • Denormalise on purpose. Analytical stores (star schemas, wide tables, ClickHouse) duplicate data to avoid joins. Do it for measured read performance, and keep a normalised source of truth.
  • Over-normalising reference data (a table per status flag) adds joins without value; use CHECK constraints or small lookup tables.
  • Store money as numeric/decimal, not floating point.
  • Natural keys change; surrogate keys (identity/serial/sequence) are stable but add a join to find the natural key.

Practice questions

  1. Normalise employee(id, dept_id, dept_name, dept_location) to 3NF.
  2. Give a table that is in 3NF but not BCNF.
  3. Why do data warehouses deliberately break 3NF?

References

relational-model · indexing-theory · safe-schema-migrations · ch-columnar-model