MSDN Library

Normalization: First Normal Form (1NF)

Database normalization is the process of organizing the columns (attributes) and tables (relations) of a relational database to minimize data redundancy and improve data integrity. The process of normalization is divided into several stages, known as normal forms. The first normal form (1NF) is the simplest level of normalization and is a prerequisite for all subsequent normal forms.

What is First Normal Form (1NF)?

A relation is in First Normal Form (1NF) if and only if all of the following conditions are met:

The most crucial aspect of 1NF is the concept of atomicity. If a column can hold multiple values, or a group of related values, it is not atomic.

Example of a Relation NOT in 1NF

Consider a table storing customer orders:


| OrderID | CustomerName | Products        |
|---------|--------------|-----------------|
| 101     | Alice Smith  | Laptop, Mouse   |
| 102     | Bob Johnson  | Keyboard        |
| 103     | Alice Smith  | Monitor, Webcam |
            

In this example, the Products column is not atomic because it contains multiple values (e.g., "Laptop, Mouse") separated by a comma. This violates the atomicity rule for 1NF.

Example of a Relation in 1NF

To bring the previous example into 1NF, we need to ensure each cell has an atomic value. This can be achieved by repeating the order information for each product in an order. Often, this involves creating a new table or restructuring the existing one.

A common approach is to use a separate table for products within an order:

Table: Orders


| OrderID | CustomerName |
|---------|--------------|
| 101     | Alice Smith  |
| 102     | Bob Johnson  |
| 103     | Alice Smith  |
            

Table: OrderItems


| OrderItemID | OrderID | ProductName |
|-------------|---------|-------------|
| 1           | 101     | Laptop      |
| 2           | 101     | Mouse       |
| 3           | 102     | Keyboard    |
| 4           | 103     | Monitor     |
| 5           | 103     | Webcam      |
            

In this structure:

Benefits of 1NF

Achieving 1NF is a fundamental step in designing robust and maintainable relational databases. It lays the groundwork for preventing data anomalies and simplifying database operations.