What is database normalization and how far should I go?

poze 3 months ago411 gadeen

0

My teacher talks about 1NF, 2NF, 3NF. In real projects, do people actually normalize? When is denormalizing OK?

Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

poze 3 months ago

1 Repons

7
✓
✓ Repons yo aksepte

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.

Konekte pou di lòt moun si li te mache.

answered 3 months ago

Sign in and verify your email to post an answer.