BeginnerCoder
intermediate#Database Normalization#Database Design

Understanding Database Normalization

This article was AI-drafted and has not been reviewed yet. Spotted a mistake? Tell us.

Learn the principles of database normalization and how to apply them to your database design.

Introduction to Database Normalization

Database normalization is the process of organizing the data in a database to minimize data redundancy and improve data integrity. There are several principles of database normalization, including first normal form (1NF), second normal form (2NF), and third normal form (3NF).

First Normal Form (1NF)

A table is in 1NF if each cell in the table contains a single value. For example, consider the following table:

Customer IDNameOrders
1John DoeOrder 1, Order 2
2Jane DoeOrder 3
This table is not in 1NF because the Orders column contains multiple values. To normalize this table, you can create a separate table for orders:
Customer IDOrder ID
------
11
12
23

Second Normal Form (2NF)

A table is in 2NF if it is in 1NF and each non-key attribute in the table depends on the entire primary key. For example, consider the following table:

Order IDCustomer IDOrder Date
112022-01-01
212022-01-15
322022-02-01
This table is not in 2NF because the Order Date column depends only on the Order ID column, not the Customer ID column. To normalize this table, you can create a separate table for orders:
Order IDOrder Date
------
12022-01-01
22022-01-15
32022-02-01

Third Normal Form (3NF)

A table is in 3NF if it is in 2NF and there are no transitive dependencies. For example, consider the following table:

Customer IDNameSalesperson
1John DoeJane Smith
2Jane DoeJohn Smith
This table is not in 3NF because the Salesperson column depends on the Customer ID column, which depends on the Name column. To normalize this table, you can create a separate table for salespeople:
Salesperson IDName
------
1Jane Smith
2John Smith
Keep going with Database Normalization

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.