Database Normalization and SQL Concepts
Normalization and Its Need
What is the Need of Normalization?
Normalization is a process in database design that helps to:
1. Eliminate data redundancy (repeating data)
2. Avoid update, insert, and delete anomalies
3. Ensure data consistency
4. Improve database efficiency and integrity
5. Organize data into related tables for better structure and scalability
Normalization Forms and Their Conditions
1NF (First Normal Form)
- All attributes must contain atomic (indivisible) values
- No repeating groups or arrays in a single column
2NF (Second Normal Form)
- Must be in 1NF
- No partial dependency: Non-prime attributes must depend on the whole primary key (applies only to
composite keys)
3NF (Third Normal Form)
- Must be in 2NF
- No transitive dependency: Non-prime attributes should not depend on other non-prime attributes
BCNF (Boyce-Codd Normal Form)
- Must be in 3NF
- For every functional dependency X -> Y, X must be a super key
Quick Example:
Database Normalization and SQL Concepts
Assume a table: Student(StudentID, Name, CourseID, CourseName, Instructor)
- If CourseName depends only on CourseID -> it's a transitive dependency
- If Instructor also depends on CourseID -> this violates 3NF
- If CourseID is not a super key and determines Instructor -> violates BCNF
Summary Table:
Normal Form | Focus | Eliminates
------------|------------------------------|--------------------------
1NF | Atomic values, no repetition | Repeating groups
2NF | Full dependency on PK | Partial dependencies
3NF | Non-transitive dependencies | Transitive dependencies
BCNF | Stronger 3NF | Non-superkey dependencies