Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. The goal is to ensure that the database is efficient and maintains data integrity. The process involves applying a series of rules called normal forms.
####First Normal Form (1NF) Definition: A table is in the First Normal Form (1NF) if:
- All columns contain atomic (indivisible) values.
- Each column contains values of a single type.
- Each column contains unique values or a unique combination of values.
- Each row is unique.
Second Normal Form (2NF)
Definition: A table is in the Second Normal Form (2NF) if:
- It is in 1NF.
- All non-key attributes are fully functionally dependent on the primary key.
- To convert it to 2NF, we remove partial dependencies by creating separate tables.
Third Normal Form (3NF)
Definition: A table is in the Third Normal Form (3NF) if:
- It is in 2NF.
- All non-key attributes are not only fully functionally dependent on the primary key but also non-transitively dependent (i.e., no transitive dependencies).
- To convert it to 3NF, we remove transitive dependencies by creating separate tables.
Summary
- First Normal Form (1NF): Ensures that all columns contain atomic values and each row is unique.
- Second Normal Form (2NF): Ensures that all non-key attributes are fully functionally dependent on the primary key, eliminating partial dependencies.
- Third Normal Form (3NF): Ensures that all non-key attributes are non-transitively dependent on the primary key, eliminating transitive dependencies.
By applying these normal forms, you can design a database that is efficient, reduces redundancy, and maintains data integrity.