Learn SQL Lesson

Why Normalization Matters

Normalization is the process of splitting data into related tables so each fact is stored in the right place only once. We do this to reduce duplication and keep data consistent.

Imagine a single table that stores orders like this:

order_id | customer_name | customer_email | customer_city | product_name | product_price -------- | ------------- | ---------------- | ------------- | ------------ | ------------- 1001 | Alice Kim | alice@shop.test | Berlin | Keyboard | 89.00 1002 | Alice Kim | alice@shop.test | Berlin | Mouse | 25.00 1003 | Ben Fox | ben@shop.test | Hamburg | Keyboard | 89.00

Alice's email and city are repeated on every order row. The Keyboard price is also repeated. That repetition causes problems:

• Update anomaly: if Alice moves, you must update many rows • Insert anomaly: you may not be able to add a new product until somebody orders it • Delete anomaly: deleting the last order for a product can accidentally remove the product information itself

Normalization solves this by separating `customers`, `products`, `orders`, and `order_items` into their own tables. Each table has a clear purpose, and relationships are connected with keys.

Open interactive editor