Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Databases, SQL & BIDatabase conceptMiddleCommonTheory

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

Normalized order/customer model
Dialect · Portable SQLRuntime · SQLite sample DB

Runs against the resettable SQLite sample database used by the playground.

SQL
SQLite · sample DB · browser sandbox
Result
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.

#database#sql#normalization#data-model

Sources

PostgreSQL documentationPostgreSQL Global Development Group · Relational modelling, SQL, joins, constraints, transactions, concurrency, indexes, query plans and recovery