Use it when designing schemas or fixing update anomalies.
Relational Model and Normalization
The relational model stores data in tables (relations) of rows and columns linked by keys; normalization removes redundancy (1NF, 2NF, 3NF) so each fact is stored once.
1. Repeated groups in a column? → 1NF.
2. Attributes depending on part of a key? → 2NF.
3. Attributes depending on non-key columns? → 3NF.
4. Check with sample queries: SELECT col, count(*) … GROUP BY col HAVING count(*)>1.
5. Document deliberate denormalisation.
entities → tables with keys → relationships by foreign keys → normalised schema
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Review the schema for repeated groups and multi-valued columns (comma-separated lists). Confirm joins use indexed key columns.
Step 2 Common failures Narrow the fault
Storing lists in a text column prevents indexing and integrity checks. Over-normalizing into many tiny tables makes simple queries need many joins. Denormalized copies drift out of sync without triggers or jobs to maintain them.
Normalise to 3NF by default; denormalise deliberately for performance with a plan to keep copies consistent.
SELECT col, count(*) … GROUP BY col HAVING count(*)>1— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
ReferenceWhat it is1 section · depth on demand
How it works
Joins combine normalized tables at query time. Normalization prevents update anomalies, where changing a customer's address in one row leaves an old address in another. Read-heavy reporting systems sometimes denormalize on purpose for speed.
ReferenceImportant terms & boundaries3 sections · depth on demand
Normal forms in short
| Form | Rule |
|---|---|
| 1NF | Atomic values, no repeating groups |
| 2NF | No partial dependency on part of a composite key |
| 3NF | No dependency between non-key columns |
Example: storing customer address in every order row violates 3NF — move it to a customers table referenced by customer_id. Denormalise deliberately for read performance (reporting tables, materialized views), not by accident.
In depth
Worked example — from one wide table to third normal form
Start: orders(order_id, customer_name, customer_email, customer_city, product1, qty1, product2, qty2)
1. 1NF — remove repeating groups. Product/quantity pairs move to order_lines(order_id, line_no, product_id, qty); one row per line, no product1/product2 columns.
2. 2NF — remove partial dependencies. In order_lines the key is (order_id, line_no); product name and price depend on product_id only, so they live in products(product_id, name, price).
3. 3NF — remove transitive dependencies. Customer name, email and city depend on the customer, not the order: customers(customer_id, name, email, city) and orders(order_id, customer_id, ordered_at).
Anomalies this prevents
| Anomaly | In the wide table |
|---|---|
| Update | A customer's new email must be changed in every order row; missed rows disagree |
| Insert | A customer cannot exist without an order |
| Delete | Deleting the last order deletes the customer's details |
When to denormalise deliberately
- Historical facts: store the price on the order line at the time of sale; copying it is correct, not redundant.
- Read-heavy reporting: summary tables or materialised views refreshed on a schedule.
- Measured hot paths: a duplicated column kept in sync by a trigger or application code, with a check that finds drift.
Denormalise after measuring a real query problem, and document which copy is the source of truth.
Common mistakes
- Over-normalising read-heavy data without measuring.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.