Normalization
A process used to organize data in a database to reduce redundancy and improve data integrity.
- The normalisation process involves dividing large tables into smaller, related tables.
- This ensures that the data dependencies are logical.
- There are three normalisation forms:
- 1NF
- 2NF
- 3NF
1NF: Eliminate Repeating Groups
- 1NF requires that each table has a primary key and that each attribute contains atomic values.
- This means that there are no repeating groups or arrays in any column.
- Consider a table with the following data:
| StudentID | Name | Courses |
|---|---|---|
| 1 | Alice | Math, Science |
| 2 | Bob | English |
- This table is not in 1NF because the Courses column contains multiple values.
- To convert this table to 1NF, we create separate rows for each course:
| StudentID | Name | Course |
|---|---|---|
| 1 | Alice | Math |
| 1 | Alice | Science |
| 2 | Bob | English |
- To achieve 1NF, ensure that each attribute contains only a single value.
2NF: Eliminate Partial Dependencies
- 2NF builds on 1NF by eliminating partial dependencies.
- A partial dependency occurs when a non-prime attribute is dependent on only part of a composite primary key.
- Non-prime attributes are attributes that are not part of any candidate key.