The first normal form (1NF) is a rule in relational database design that ensures a table inside a database has a specific structure. This rule helps to avoid redundancy and maintain data integrity. The requirements of the first normal form are as follows:
- Atomic Values: Each attribute (column) in a table must contain atomic (indivisible) values. This means each value in a column must be a single value, not a list or set of values.
- Unique Column Names: Each column in a table must have a unique name to avoid confusion.
- Unique Row Identifiability: Each row in the table must be uniquely identifiable. This is usually achieved through a primary key, ensuring that no two rows have identical values in all columns.
- Consistent Column Order: The order of columns should be fixed and unambiguous.
Here is an example of a table that is not in the first normal form:
CustomerID |
Name |
PhoneNumbers |
1 |
Alice |
12345, 67890 |
2 |
Bob |
54321 |
3 |
Carol |
98765, 43210, 13579 |
In this table, the "PhoneNumbers" column contains multiple values per row, which violates the first normal form.
To bring this table into the first normal form, you would restructure it so that each phone number has its own row:
CustomerID |
Name |
PhoneNumber |
1 |
Alice |
12345 |
1 |
Alice |
67890 |
2 |
Bob |
54321 |
3 |
Carol |
98765 |
3 |
Carol |
43210 |
3 |
Carol |
13579 |
By restructuring the table this way, it now meets the conditions of the first normal form, as each cell contains atomic values.