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_idcustomer_namecustomer_emailitem
1Ana Lopezana@example.comPen
2Ana Lopezana@example.comNotebook
3Ana Lopezana@exmaple.comRuler

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.idnameemail
7Ana Lopezana@example.com
order_idcustomer_iditem
17Pen
27Notebook
37Ruler

Now an email change touches 1 row, however many orders Ana has.

A simple payback table

QuestionDuplicatedSplit
Rows to update when an email changesone per order1
Places a typo can hideevery order row1
Space used per order for customer detailsthe full name and emailone small number
Effort to set uplowesta 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.