← Lesson
BitWithBite
SQL · Quick Reference

Lesson 13 — Normalization 1NF 2NF 3NF Cheat Sheet

SQL
In one line: Without normalization you get three types of anomalies:

Key Ideas

1Why Normalize?. Without normalization you get three types of anomalies:
21NF — First Normal Form. Rule: Every column must contain atomic (single, indivisible) values. No repeating groups or sets of values in one cell.
32NF — Second Normal Form. Rule: Must be in 1NF and have no partial dependencies. Every non-key column must depend on the entire primary key — not just part of it. This only matters when the PK ...
43NF — Third Normal Form. Rule: Must be in 2NF and have no transitive dependencies. A non-key column must not depend on another non-key column.
5When to Denormalize. Normalization is great for OLTP (Online Transaction Processing) systems — apps that INSERT, UPDATE, DELETE frequently. However, OLAP (Online Analytical Processing) sys...

Code Examples

-- VIOLATES 1NF: courses column stores multiple values -- student_id | name | courses -- 1 | Sara | Math, Science, English -- CORRECT 1NF: separate rows per course -- student_id | name | course -- 1 | Sara | Math -- 1 ...
-- VIOLATES 2NF: student_name depends only on student_id, not course_id -- (student_id, course_id) → student_name, course_name, grade -- student_name depends on PART of the composite key -- FIX: decompose into three tables -- students(id, student_name...
-- VIOLATES 3NF: zip_code determines city (transitive dependency) -- order_id → customer_zip → customer_city -- customer_city depends on zip_code, not order_id -- FIX: extract zip codes into their own table -- orders: order_id, customer_id, zip_code ...