Pcornel
Browse topics
Options
Recent
Favorites
Databases · Technical reference

Relational Model and Normalization

Direct answer

The relational model stores data in tables (relations) of rows and columns linked by keys; normalization removes redundancy (1NF, 2NF, 3NF) so each fact is stored once.

When to use this

Use it when designing schemas or fixing update anomalies.

First 30 seconds

1. Repeated groups in a column? → 1NF.

2. Attributes depending on part of a key? → 2NF.

3. Attributes depending on non-key columns? → 3NF.

4. Check with sample queries: SELECT col, count(*) … GROUP BY col HAVING count(*)>1.

5. Document deliberate denormalisation.

Operational verification

entities → tables with keys → relationships by foreign keys → normalised schema

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
MariaDB / MySQL / PostgreSQL / Microsoft SQL Server concepts
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformMariaDB / MySQL / PostgreSQL / Microsoft SQL Server concepts
Scope / prerequisiteUse it when designing schemas or fixing update anomalies.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Review the schema for repeated groups and multi-valued columns (comma-separated lists). Confirm joins use indexed key columns.

Step 2 Common failures Narrow the fault

Storing lists in a text column prevents indexing and integrity checks. Over-normalizing into many tiny tables makes simple queries need many joins. Denormalized copies drift out of sync without triggers or jobs to maintain them.

Key points

Normalise to 3NF by default; denormalise deliberately for performance with a plan to keep copies consistent.

Key checks
  • SELECT col, count(*) … GROUP BY col HAVING count(*)>1 — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version
ReferenceWhat it is1 section · depth on demand

How it works

Joins combine normalized tables at query time. Normalization prevents update anomalies, where changing a customer's address in one row leaves an old address in another. Read-heavy reporting systems sometimes denormalize on purpose for speed.

ReferenceImportant terms & boundaries3 sections · depth on demand

Normal forms in short

FormRule
1NFAtomic values, no repeating groups
2NFNo partial dependency on part of a composite key
3NFNo dependency between non-key columns

Example: storing customer address in every order row violates 3NF — move it to a customers table referenced by customer_id. Denormalise deliberately for read performance (reporting tables, materialized views), not by accident.

In depth

Worked example — from one wide table to third normal form

Start: orders(order_id, customer_name, customer_email, customer_city, product1, qty1, product2, qty2)

1. 1NF — remove repeating groups. Product/quantity pairs move to order_lines(order_id, line_no, product_id, qty); one row per line, no product1/product2 columns.

2. 2NF — remove partial dependencies. In order_lines the key is (order_id, line_no); product name and price depend on product_id only, so they live in products(product_id, name, price).

3. 3NF — remove transitive dependencies. Customer name, email and city depend on the customer, not the order: customers(customer_id, name, email, city) and orders(order_id, customer_id, ordered_at).

Anomalies this prevents

AnomalyIn the wide table
UpdateA customer's new email must be changed in every order row; missed rows disagree
InsertA customer cannot exist without an order
DeleteDeleting the last order deletes the customer's details

When to denormalise deliberately

  • Historical facts: store the price on the order line at the time of sale; copying it is correct, not redundant.
  • Read-heavy reporting: summary tables or materialised views refreshed on a schedule.
  • Measured hot paths: a duplicated column kept in sync by a trigger or application code, with a check that finds drift.

Denormalise after measuring a real query problem, and document which copy is the source of truth.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • Over-normalising read-heavy data without measuring.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
relational model and normalizationdatabase normalization 3nfrelational model
Confirmation

Confirm action

Continue?