🌐 English

Home › Guides

Database Normalization Basics: First, Second and Third Normal Form

Normalization is a design method that splits tables so that each fact is written in only one place. Instead of heavy terminology, we follow a single order table and see how it is tidied from first to third normal form.

Why normalization is needed

Putting customers, products and orders in one big table feels convenient at first. But the same customer address repeats once per order, a changed address must be corrected on every row, and if even one row is missed, the same customer ends up with two different addresses. These problems are called anomalies.

There are three kinds. An update anomaly is when only some copies get changed, an insertion anomaly is when a new product cannot be registered without an order, and a deletion anomaly is when removing the last order also erases the customer. Normalization prevents all three in advance.

First normal form: one value per cell

First normal form requires that each cell holds a single value. If the product cell of an order table says pencil, notebook, eraser separated by commas, it is not in first normal form. Such a cell makes it hard to find orders containing a particular product and hard even to count items.

The fix is to write one row per product in each order. Then the pair of order number and product identifies a row, and the repeating group disappears.

Second normal form: separate facts that depend on part of the key

Second normal form matters when the primary key has two or more columns. If a table keyed by order number and product number also stores product name and unit price, those values depend only on the product number, not on the whole key. The name and price repeat every time that product is ordered.

The fix is to make a product table keyed by product number only, move name and price there, and leave only order number, product number and quantity in the order detail table. If the price changes, you correct a single place in the product table.

Third normal form: separate facts that depend on non-key columns

Third normal form removes cases where one non-key column determines another non-key column. If an order table holds customer number along with customer name and city, the name and city belong to the customer, not to the order. They are determined only indirectly through the order, which is called a transitive dependency.

The fix is to create a customer table, move name and city into it, and leave only the customer number in the order table. Now when a customer moves, changing one row in the customer table is reflected in every order.

Limits of normalization, and checking with an ERD

The more you normalize, the more tables there are and the more joining queries need. For report-oriented data that is read far more than written, designers sometimes allow duplication on purpose. A safe approach is to reach third normal form first and only step back carefully when a real performance problem appears.

After splitting tables, it helps to check the result as a picture. Paste your table definitions into the SQL to ERD tool on this site and the tables and relationships are drawn, so you can see whether the same fact repeats across tables and whether any foreign key is missing.