Normalization
Organize tables so each fact is stored in exactly one place, not copied everywhere it's needed.
What is it?
Imagine an orders table that stores the customer's name and email on every order, instead of a user_id. If the customer changes their email, you must update every order they've ever placed. Miss one, and your data disagrees with itself.
Normalization restructures tables so each fact is stored once, and everything else references it (usually with a foreign key) instead of copying it. Orders are still linked to customer info; that info just lives in one authoritative place.
Explain like I'm 10
Storing a customer's email on every order is like writing a friend's phone number on every letter you send them. Normalization is writing it once in your address book and pointing there everywhere else. Update it once, and every reference is correct.
Examples
Before: duplicated data
-- orders table (not normalized)
id | customer_name | customer_email | total_cents
1 | Amara Musa | amara@example.com | 4599
2 | Amara Musa | amara@example.com | 1200
3 | Amara Musa | amara@example.com | 800
-- Amara's email is repeated on every single order.
-- Changing it means updating all 3 rows, and it's easy to miss one.The customer's name and email are copied into every order. Changing her email means finding and fixing every one of these rows.
After: normalized into two tables
-- users table
id | name | email
2 | Amara Musa | amara@example.com
-- orders table (normalized)
id | user_id | total_cents
1 | 2 | 4599
2 | 2 | 1200
3 | 2 | 800
-- Amara's email now lives in exactly one row.
-- Updating it there instantly applies everywhere it's referenced.Amara's details now live in one row. Each order references her by user_id, so updating her email changes one row, and every order shows the correct value through a join.
How it works
Normalization is usually described in stages called normal forms. Each fixes a specific kind of duplication or inconsistency, such as a column holding several values at once, or non-key columns depending on only part of a multi-column key.
In everyday design, you mostly apply one idea: if a fact could change and would need updating in more than one row, move it to its own table and reference it with a foreign key.
Why does it exist?
Duplicated data drifts apart. A fact stored in ten places will eventually disagree with itself when someone updates nine and misses one. Normalization gives each fact one authoritative home, so there's never a question of "which copy is correct."
When to use it
Normalize when information belongs to one entity (a customer's email, a product's price) and may change over time. Keeping it in one place makes updates safe. This is the default for most relational schema design.
When not to use it
Heavily normalized data needs more joins to reassemble, which can slow read-heavy systems. Sometimes some duplication (denormalization) is accepted for speed. For example, storing a product's name on a historical order line item keeps old receipts showing the name at purchase time, even if the product is renamed later.
Common mistakes
Storing a repeated value (like a customer's address) on every related row instead of referencing one source table.
Over-normalizing every detail, so simple queries need long chains of joins.
Thinking normalization just means 'more tables'. The goal is removing duplicated, update-prone facts, not adding tables.
Practice exercises
- Easy:
Explain what could go wrong if a shipping address were copied onto every order a customer places, instead of stored once.
- Medium:
An 'employees' table repeats the department name and manager on every row. Redesign it as two normalized tables.
- Hard:
Describe a realistic case where deliberately keeping some duplicated data (denormalization) is a reasonable tradeoff.
Interview questions
What problem does normalization solve?
It stops the same fact being copied across many rows, where the copies could drift out of sync.
What's the tradeoff of a highly normalized schema?
Reassembling related data needs more joins, adding query complexity and cost compared with some duplication.
What is denormalization?
Deliberately duplicating some data, accepting the inconsistency risk, for faster reads or simpler queries.