Normalization

Normalization is the process of organizing a database into multiple related tables to reduce duplicate data and avoid inconsistencies. It splits data so each fact is stored in just one place.

SQL

Instead of repeating a customer's address on every one of their orders, you store the customer once in a customers table and link orders to it with a foreign key. This keeps data consistent and easier to update.

Normalization is described in 'normal forms' (1NF, 2NF, 3NF and beyond), each adding stricter rules. The trade-off is that highly normalized data may need more joins to read back together.

Examples

SQL

-- Instead of one big table, split into two:
CREATE TABLE customers (id INT PRIMARY KEY, name TEXT);
CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT REFERENCES customers(id)
);

Output:

Customer data stored once, referenced by many orders.

Learn it in a lesson

See also

Back to the Dictionary