Database Normalization
Normalization in DBMS
Normalization is a process in relational database design that organizes data to reduce redundancy and
improve data integrity.
It involves decomposing a table into smaller tables and defining relationships between them.
Why Normalization is Needed:
1. Avoid Data Redundancy
2. Ensure Data Consistency
3. Improve Data Integrity
4. Make Queries Efficient
5. Prevent Anomalies
Normal Forms:
1NF (First Normal Form)
- Atomic values (no repeating groups or arrays)
- Each cell must contain a single value
Example (Not in 1NF):
| StudentID | Name | Courses |
|-----------|-------|-----------------|
|1 | Alice | Math, Physics |
|2 | Bob | Chemistry |
1NF:
| StudentID | Name | Course |
|-----------|-------|------------|
|1 | Alice | Math |
|1 | Alice | Physics |
Database Normalization
|2 | Bob | Chemistry |
2NF (Second Normal Form)
- Must be in 1NF
- No partial dependency
Example (Not in 2NF):
| StudentID | Course | InstructorName |
|-----------|----------|----------------|
|1 | Math | Mr. A |
|1 | Physics | Mr. B |
2NF (Decomposed):
Table 1: Student_Courses
| StudentID | Course |
|-----------|--------|
|1 | Math |
|1 | Physics|
Table 2: Course_Instructors
| Course | InstructorName |
|----------|----------------|
| Math | Mr. A |
| Physics | Mr. B |
3NF (Third Normal Form)
- Must be in 2NF
- No transitive dependency
Example (Not in 3NF):
Database Normalization
| StudentID | Name | Department | HOD |
|-----------|--------|------------|------------|
|1 | Alice | Science | Dr. Smith |
|2 | Bob | Arts | Dr. Allen |
3NF:
Table 1: Students
| StudentID | Name | Department |
|-----------|--------|------------|
|1 | Alice | Science |
|2 | Bob | Arts |
Table 2: Departments
| Department | HOD |
|------------|------------|
| Science | Dr. Smith |
| Arts | Dr. Allen |
BCNF (Boyce-Codd Normal Form)
- Stricter version of 3NF
- Every determinant must be a candidate key
Example (Not in BCNF):
| StudentID | Course | Instructor |
|-----------|--------|------------|
|1 | Math | Mr. A |
|2 | Math | Mr. A |
BCNF:
Table 1: Course_Instructors
Database Normalization
| Course | Instructor |
|--------|------------|
| Math | Mr. A |
Table 2: Student_Courses
| StudentID | Course |
|-----------|--------|
|1 | Math |
|2 | Math |
Summary:
| Normal Form | Requirement | Removes |
|-------------|-------------------------------------|-------------------------|
| 1NF | Atomic values | Repeating groups |
| 2NF | No partial dependency | Partial dependencies |
| 3NF | No transitive dependency | Transitive dependencies |
| BCNF | Determinant must be a candidate key | Any dependency issues |