What is database normalization and how far should I go?
asked 3 months ago414 viewsen
My teacher talks about 1NF, 2NF, 3NF. In real projects, do people actually normalize? When is denormalizing OK?
AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
1 Answer
Normalization means storing each fact once, so updates can't leave contradictory copies.
- 1NF: no repeating groups. Not phone1, phone2, phone3 columns, but a phones table. - 2NF/3NF: every non-key column depends on *the key, the whole key, and nothing but the key*. Don't store customer_city in orders; reference customers.
In practice, design to 3NF by default. It prevents a whole class of data bugs.
Denormalize deliberately when you've measured a read-performance need. Typical cases: - cached counters (answer_count on questions), kept in sync in the same transaction or by a trigger; - snapshots that *should* be frozen, such as the price on an invoice line (the product price can change later); - read models, materialized views, or analytics tables.
If you denormalize, document the source of truth and how the copy is kept in sync.
Sign in to tell others whether this worked.
Sign in and verify your email to post an answer.