Skip to content
Databases for Developers

Lesson 3 of 10 · 22 min

x
3/10

Lesson position in the course — not completion. Use Mark Complete to track finished lessons (saved in this browser).

Schema Design & Normalization

Schema design is the most consequential decision in a relational database. A good schema prevents anomalies: inserting a row should not require duplicating data, and deleting a row should not accidentally destroy unrelated information.

Normalization is the process of organizing tables to eliminate redundancy. First Normal Form (1NF) requires atomic values — no arrays in a cell. Second Normal Form (2NF) removes partial dependencies — every non-key column must depend on the whole primary key. Third Normal Form (3NF) removes transitive dependencies — non-key columns should not depend on other non-key columns. In practice, most application schemas target 3NF, then strategically denormalize hot read paths for performance.

Before
Denormalized (redundant data)
1orders2┌────────┬──────────────┬───────────────────┬───────────┐3│ id     │ customer_name│ customer_email     │ product   │4├────────┼──────────────┼───────────────────┼───────────┤51      │ Alice        │ alice@example.com  │ Laptop    │62      │ Alice        │ alice@example.com  │ Mouse     │7└────────┴──────────────┴───────────────────┴───────────┘
After
Normalized (3NF)
1customers              orders2┌────┬───────┬──────┐   ┌────┬─────────────┬────────┐3│ id │ name  │email │   │ id │ customer_id │product │4├────┼───────┼──────┤   ├────┼─────────────┼────────┤51  │ Alice │alice@│   │ 11           │ Laptop │6└────┴───────┴──────┘   │ 21           │ Mouse  │7                        └────┴─────────────┴────────┘

Check your understanding

  • What anomaly does normalization mainly prevent?Show answer

    Answer

    Redundant data that causes update/insert/delete anomalies — e.g. changing an email in one row but not another.
  • What does 3NF require beyond 2NF?Show answer

    Answer

    Non-key columns should not depend on other non-key columns (no transitive dependencies).
  • When is deliberate denormalization justified?Show answer

    Answer

    When measured hot read paths need it and you accept the update cost — not by default.
Previous

Progress is saved in this browser.

Next Lesson