What problem does database normalization solve, and when can denormalization be justified?
Answer
Normalization separates facts to reduce duplication and update, insert and delete anomalies; first, second and third normal forms progressively constrain repeating groups, partial dependencies and transitive dependencies. Denormalization deliberately duplicates or precomputes data to simplify reads or improve measured performance. Testers should verify the source of truth, write consistency, migration and repair paths, concurrency behaviour and whether performance evidence actually justifies the extra integrity risk.
Strong answer includes
- connects normalization to data anomalies
- treats denormalization as an evidence-based tradeoff
- tests consistency and repair paths
Practical example
Runs against the resettable SQLite sample database used by the playground.
Run the query to see the result.
Customer identity is stored once and referenced from orders, reducing update anomalies. A denormalized design that copied customer email into every order would need tests proving those copies stay consistent when the source value changes.
Expected result: One order resolved to its current customer record through the relationship.