Database normalization is the process of structuring a database, usually a relational database, in accordance with a series of so-called normal forms in order to reduce data redundancy and improve data integrity.
- Flexible Database Design
- Reduce Data redundancy
- Improves the data integrity
- Makes an organized Database
Normalization Types
- 1NF (First Normal Form)
- 2NF (Second Normal Form)
- 3NF (Third Normal Form)
- Boyce-Codd NF (BCNF)
First Normal Form (1NF)
For a table to be in the first Normal Form:
- It should not have repeating values in a group.
- It should not have repeating groups.
Second Normal Form (2NF)
For a table to be in the second Normal Form:
- Should be in 1NF.
- Any non-key field should entirely depend on its primary key.
- No partial dependency (Occurs when there is a composite key).
Third Normal Form (3NF)
- Should be in 2NF.
- Any non-key field must not depend on other non-key fields.
- No transitive dependency.
What is a KEY?
A KEY is a value used to identify a record in a table uniquely. It could be a single column or a combination of multiple columns.
Primary Key: A single column value used to identify a database record uniquely.
Composite Key: A primary key composed of multiple columns.
Transitive Dependency: Occurs when one non-prime column is dependent on another non-prime column.
The Risks of Non-Normalized Data
- Update Anomaly: Data inconsistency resulting from redundancy and a partial update.
- Insert Anomaly: Inability to add data due to the absence of other required data.
- Delete Anomaly: Unintended loss of data due to deletion of other records.
Conclusion
Normalization is essential for reducing redundancy and ensuring that your data remains accurate through every update, insertion, and deletion.
Happy learning!