Payback Math for Removing Duplicated Data
Beginners often store the same piece of information again and again, such as a customer's address on every order. It feels simpler at first. This page uses simple counting to show what that duplication costs later, and why splitting data into separate tables pays back.
The problem in one picture
Imagine an orders table that copies the customer's details into every row:
| order_id | customer_name | customer_email | item |
|---|---|---|---|
| 1 | Ana Lopez | ana@example.com | Pen |
| 2 | Ana Lopez | ana@example.com | Notebook |
| 3 | Ana Lopez | ana@exmaple.com | Ruler |
Notice the typo in row 3. Now the database holds two different emails for the same person, and nobody can be sure which is right.
Counting the cost
Let us count how many places must change when a fact changes.
Duplicated design. If Ana has placed 40 orders and changes her email, you must update 40 rows. Miss one, and the data disagrees with itself.
Split design. Put customers in their own table and give each order a customer_id that points to the customer:
| customers.id | name | |
|---|---|---|
| 7 | Ana Lopez | ana@example.com |
| order_id | customer_id | item |
|---|---|---|
| 1 | 7 | Pen |
| 2 | 7 | Notebook |
| 3 | 7 | Ruler |
Now an email change touches 1 row, however many orders Ana has.
A simple payback table
| Question | Duplicated | Split |
|---|---|---|
| Rows to update when an email changes | one per order | 1 |
| Places a typo can hide | every order row | 1 |
| Space used per order for customer details | the full name and email | one small number |
| Effort to set up | lowest | a little more: two tables and a JOIN |
The setup effort is paid once. The savings come back every time data changes.
The name for this idea
Splitting data so each fact is stored once is called normalisation. It has formal rules with names like "first normal form", but the beginner version is simply: one fact, one place. Our long read on why we split data into tables goes further.
Getting the data back together
Splitting tables means you need a JOIN to show an order with the customer's name:
SELECT orders.order_id, customers.name, orders.item
FROM orders
JOIN customers ON customers.id = orders.customer_id;
That one extra line is the whole "price" of the split design when reading.
When a little duplication is acceptable
Sometimes you deliberately copy a value. An invoice, for example, should keep the address the customer had at the time of purchase, even if they move later. That is not a mistake; it records history. The key is to duplicate on purpose, not by accident.
Try it yourself
Take a spreadsheet you already use. Count how many times the same person, product or place is written out in full. Each repeat is a place a typo can live, and a candidate for its own table.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.