Normalization vs Denormalization
Balance 3NF transactional purity against denormalized analytics-friendly tables.
In plain words
Normalised data stores each fact in one place; denormalised data copies facts together so reading is easier, at the risk of copies going out of date.
Think of it like…
A company's HR system keeps each fact once (an employee's department lives in one table). A report for the CEO photocopies the pieces onto one page. The report is easier to read, but if the department changes, the copies on old reports are out of date.
Where you’ve seen it
The orders application database has customers, products, orders and order_items in third normal form. For a recommendation model the team creates ml.order_items_wide with one row per order line and the customer segment, product category, price and order date already attached. Queries run 20× faster and are trivial to write, but the customer segment is a snapshot as of the order date (not today's value), and a nightly job rebuilds the table so category corrections propagate within a day.
Words you’ll hear
- 1NF / 2NF / 3NF
- Atomic values / no partial key dependence / no transitive dependence between non-key columns.
- Update anomaly
- An inconsistency caused by a fact stored in several places and changed in only some.
- Denormalised (wide) table
- A table with attributes from several sources pre-joined or duplicated.
- Point-in-time snapshot
- Attributes recorded as they were at a given date, rather than current values.
Visual diagram
Theory & deep dive
Why normalise: the three normal forms
1NF: every cell holds one atomic value (not a list like "red,blue"). 2NF: in a table with a composite key (order_id, product_id), attributes depend on the whole key: a product's name belongs in products, not in order_items. 3NF: non-key columns depend only on the key, not on each other: if customer_id determines city, put city in customers, not in orders. The result: each fact lives once, updates are cheap and consistent, constraints are easy to enforce, and storage is compact. The price is more tables and joins for reading.
Operational systems (OLTP) are normalised because they do many small, concurrent writes where anomalies matter. When you query them you'll see joins through keys and junction tables, and you must identify each table's grain before combining them.
orders(order_id, customer_id, customer_city, amount): customer_city depends on customer_id, not on order_id. Move city to customers(customer_id, city); otherwise a customer who moves has some orders with the old city and some with the new one.
When and how to denormalise for analytics
Denormalise when reads dominate and joins are costly or error-prone: reporting tables, feature tables, search indexes and wide event tables. Typical forms: a wide fact table with dimension attributes copied in; a star schema (fact plus dimensions); pre-aggregated summary tables; and entity-level feature tables (one row per customer with dozens of features). Warehouses make this cheap because columnar storage compresses repeated values and scans only the columns used.
Manage the risks. Copies go stale, so rebuild on a schedule or incrementally and record the build time. Definitions can diverge, so build wide tables from shared models rather than ad-hoc queries. History matters: attach attributes as of the event date (using a type 2 dimension or snapshots) when the model must reflect what was known then, and use current values only when that's what you want. Document the grain, the sources, and the refresh schedule, and test that row counts and totals match the normalised sources.
After building order_items_wide, check SELECT SUM(amount) FROM order_items_wide equals SELECT SUM(amount) FROM order_items for the same period and that the row count matches. A mismatch means the pre-join duplicated or dropped rows.
How it works, step by step
Step 1 of 41. Understand the normalised source
Map tables, keys and grains in the operational database and note which attributes change over time.
- Grain
- per table
When to use it & trade-offs
What it is
Normalisation organises operational data so each fact is stored once: first normal form (atomic values), second (no partial dependence on a composite key) and third (no dependence of non-key columns on other non-key columns), with tables linked by keys. It prevents update anomalies, so changing a customer's city touches one row. Denormalisation deliberately duplicates or pre-joins data (a wide orders_enriched table with customer and product attributes) to make reads simple and fast. Applications want normalised tables; analytics and machine learning usually want denormalised, one-row-per-entity tables.
Why it matters: Data scientists work across both worlds: they read normalised source systems and build denormalised feature tables. Knowing why the source is shaped as it is explains join patterns and pitfalls, and knowing the costs of denormalisation (stale copies, inconsistent definitions, point-in-time errors) helps design training tables that stay correct. It's a common design interview topic in the "analytics engineering" space.
When to reach for it
- Building feature tables for models
- Reporting layers that avoid repeated joins
- Understanding why a source schema is shaped as it is
When to avoid or be careful
- Denormalising operational databases that are heavily updated
- Wide tables with current attributes joined to historical events
- Duplicated data with no rebuild or reconciliation
Normalised vs denormalised
Strengths: No duplication; consistent updates; enforceable constraints.
Watch out: More joins to analyse; harder for non-experts.
Strengths: Clear grain; fast scans; reusable dimensions.
Watch out: Needs modelling and ETL.
Strengths: One row per entity; trivial to load.
Watch out: Easy to leak the future or go stale.
Interview signals & numbers to know
When this topic comes up
- “Normalise this table”
- “Why is the analytics schema denormalised?”
- “The report's numbers don't match the source”
- Star schemas
- Feature tables
Benchmarks & rules of thumb
- 3
- normal forms commonly applied (1NF, 2NF, 3NF)
- 20×
- query speed-up from a wide table in the example
- 1 day
- rebuild lag in the example
Common mistakes & follow-ups
Common interview mistakes
- Joining today's customer segment onto last year's orders and leaking future information into training data.
- Treating a copied attribute as authoritative after the source changed.
- Summing a column of a wide table at the wrong grain and double counting.
Likely interviewer follow-ups
- What anomalies does normalisation prevent?
- When is denormalisation appropriate?
- How do you keep a denormalised table consistent?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Normalization vs Denormalization with data science interview Q&A and hands-on practice.