Lesson 34: First Normal Form (1NF)
1NF is the basic requirement for a table to be considered part of the relational model.
Rule 1: Atomic Values
Every column in a row must contain a single, atomic value. 'Atomic' means indivisible.
- Violation Example: Having a
PhoneNumberscolumn that contains a list of multiple phone numbers ('555-1234, 555-5678'). - Correction: Split the complex data into multiple columns (
HomePhone,WorkPhone) or, preferably, move it into a separate, related table (PhoneNumberslinked by a Foreign Key).
Rule 2: No Repeating Groups
There should be no repeating columns (fields used multiple times to store the same type of data).
- Violation Example: A table with columns
Item1,Item2,Item3,Item4to store products in an order.
| OrderID | Item1 | Item2 | Item3 |
|---|---|---|---|
| 100 | Milk | Eggs | Bread |
| 101 | Chair | NULL | NULL |
- Correction: Create a separate
OrderItemstable and link it back to theOrderstable using a Foreign Key (creating a 1:N relationship).
| OrderID (FK) | ItemName |
|---|---|
| 100 | Milk |
| 100 | Eggs |
| 100 | Bread |
| 101 | Chair |
This structure ensures we adhere to the 1NF rule: each cell holds only one value, and there are no repeating structural groups.