Database normalization (1NF to 3NF)
One shop table that repeats itself is split, rule by rule, into three that cannot contradict each other: first, second and third normal form on three orders.
In 30 seconds
Normalization means arranging tables so that each fact is stored in exactly one place. When a fact is copied into several rows, the copies can drift apart: change one, miss another, and the database now holds two answers.
Three rules do most of the work. 1NF: one value per cell. 2NF: every column depends on the whole key. 3NF: and on nothing but the key.
The result is more, narrower tables linked by keys. Reading the full picture back takes joins.
Database normalization (1NF to 3NF), step by step
Customer names act as keys here to keep the tables small; a real schema would use a customer id. Normal forms beyond 3NF (BCNF, 4NF, 5NF) exist and are not covered.
- Step 1: One wide table. A small shop records each order on one line: what was bought, who bought it, and where they live. It reads well, but Ana’s city is written on two lines, and one cell holds a whole list of items.
- Step 2: Copies drift apart. Ana moves to Quito, and the change reaches only one of her two rows. Now the table gives two answers to one question. This is an update anomaly; duplication also causes delete and insert anomalies.
- Step 3: 1NF: one value per cell. First normal form: every cell holds a single value, and a key identifies each row. The list in order 10 becomes two rows, so order_id alone no longer picks out a row; the key is the pair (order_id, item).
- Step 4: 2NF: the whole key. Second normal form: no column may depend on only part of the key. qty needs both order_id and item, but customer and city follow from order_id alone. They move to their own table, keyed by order_id.
- Step 5: 3NF: only the key. Third normal form: a non-key column may not depend on another non-key column. City is a fact about the customer, not about the order, so customers get their own table. Ana and Lima now appear together exactly once.
- Step 6: One fact, one place. Ana moves to Quito, and this time exactly one cell changes. Every order that names Ana picks up the new city, because orders store only her key. A key stored in another table like this is called a foreign key.
- Step 7: The cost: joins. The price is paid when reading. The original view, one line per item with customer and city, now has to be rebuilt by joining three tables. Systems that read far more than they write sometimes keep copies on purpose for that reason.
Try it yourself
Learn this first
Nothing. This concept starts from scratch.
Learn next
Spotted a mistake on this page?