Database Management System ยท Unit 5
Normalization and Database Design
Exam-focused notes for Normalization and Database Design (Database Management System, BIT202): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
Normalization and Database Design in short
Good table design avoids repeated data and update errors. Normalization is the step-by-step method used to reach such a design. It uses functional dependencies to find and remove bad structure.
What this unit covers
- Normalization purpose and need
- Functional dependencies
- First normal form
- Second normal form
- Third normal form
- Quality measures for relational schema design
Normalization purpose and need
2082 ยท 10 marks
Why is normalization required? Define 1NF, 2NF and 3NF with suitable examples.[10]
Show solved answerHide answer
Normalization: Need, 1NF, 2NF, and 3NF
Why is Normalization Required?
Normalization is the process of organizing a relational database to reduce data redundancy and improve data integrity by decomposing large, poorly structured tables into smaller, well-structured ones.
Problems Without Normalization (Anomalies)
Consider the following unnormalized table:
| StudentID | StudentName | CourseID | CourseName | InstructorID | InstructorName |
|---|---|---|---|---|---|
| 1 | Ram | C01 | DBMS | I01 | Dr. Sharma |
| 1 | Ram | C02 | OS | I02 | Dr. Gupta |
| 2 | Sita | C01 | DBMS | I01 | Dr. Sharma |
1. Insertion Anomaly: A new course cannot be inserted unless at least one student is enrolled in it. The course data depends on student data being present.
2. Deletion Anomaly: If Student 2 (Sita) drops Course C01, the information about Dr. Sharma teaching DBMS is also lost.
3. Update Anomaly: If Dr. Sharma's name changes, it must be updated in every row where C01 appears. Missing even one row causes inconsistency.
Goals of Normalization
- Eliminate redundant data
- Ensure data dependencies make sense
- Make the database easier to maintain
- Reduce storage space
First Normal Form (1NF)
Definition
A relation is in 1NF if:
- All attributes contain atomic (indivisible) values
- There are no repeating groups or multi-valued attributes
- Each column contains values of a single type
- Each row is uniquely identifiable
Example
Violation of 1NF:
| StudentID | StudentName | Courses |
|---|---|---|
| 1 | Ram | DBMS, OS |
| 2 | Sita | DBMS |
Here, the Courses column has multiple values -- this violates 1NF.
After converting to 1NF:
| StudentID | StudentName | Course |
|---|---|---|
| 1 | Ram | DBMS |
| 1 | Ram | OS |
| 2 | Sita | DBMS |
Now every attribute is atomic. The table is in 1NF.
Second Normal Form (2NF)
Definition
A relation is in 2NF if:
- It is already in 1NF
- Every non-key attribute is fully functionally dependent on the entire primary key (no partial dependency)
Partial Dependency: A non-key attribute depends on only a part of a composite primary key.
Example
Consider the table (Primary Key = {StudentID, CourseID}):
| StudentID | CourseID | StudentName | CourseName | Grade |
|---|---|---|---|---|
| 1 | C01 | Ram | DBMS | A |
| 1 | C02 | Ram | OS | B |
| 2 | C01 | Sita | DBMS | A |
Functional Dependencies:
- {StudentID, CourseID} --> Grade (full dependency -- OK)
- StudentID --> StudentName (partial dependency -- violates 2NF)
- CourseID --> CourseName (partial dependency -- violates 2NF)
After converting to 2NF (decompose):
Student Table:
| StudentID | StudentName |
|---|---|
| 1 | Ram |
| 2 | Sita |
Course Table:
| CourseID | CourseName |
|---|---|
| C01 | DBMS |
| C02 | OS |
Enrollment Table:
| StudentID | CourseID | Grade |
|---|---|---|
| 1 | C01 | A |
| 1 | C02 | B |
| 2 | C01 | A |
Now all non-key attributes are fully dependent on the whole primary key. The tables are in 2NF.
Third Normal Form (3NF)
Definition
A relation is in 3NF if:
- It is already in 2NF
- There is no transitive dependency -- no non-key attribute depends on another non-key attribute
Transitive Dependency: If A --> B and B --> C, then A --> C is a transitive dependency (C depends on A through B).
Example
Consider the table (Primary Key = StudentID):
| StudentID | StudentName | DeptID | DeptName |
|---|---|---|---|
| 1 | Ram | D01 | Computer |
| 2 | Sita | D02 | Physics |
| 3 | Hari | D01 | Computer |
Functional Dependencies:
- StudentID --> DeptID (direct dependency -- OK)
- DeptID --> DeptName (DeptName depends on DeptID, not on StudentID)
- Therefore: StudentID --> DeptID --> DeptName (transitive dependency -- violates 3NF)
After converting to 3NF (decompose):
Student Table:
| StudentID | StudentName | DeptID |
|---|---|---|
| 1 | Ram | D01 |
| 2 | Sita | D02 |
| 3 | Hari | D01 |
Department Table:
| DeptID | DeptName |
|---|---|
| D01 | Computer |
| D02 | Physics |
Now there is no transitive dependency. Both tables are in 3NF.
Summary Table
| Normal Form | Condition |
|---|---|
| 1NF | All attributes are atomic; no repeating groups |
| 2NF | 1NF + No partial dependency on composite primary key |
| 3NF | 2NF + No transitive dependency; every non-key attribute depends on the key alone |
Conclusion
Normalization is required because an unnormalized table stores the same fact in many rows, which wastes space and, more seriously, allows the copies to disagree. Removing repeating groups gives 1NF, removing partial dependency on part of a composite key gives 2NF, and removing transitive dependency through a non-key attribute gives 3NF. Each step replaces one table by two smaller tables joined on a key, so the insertion, deletion and update anomalies disappear while the original information can still be recovered by a join. Most practical database designs stop at 3NF (or BCNF), since further decomposition begins to cost more in join time than it saves in redundancy.
0 ยท 5 marks
Why normalization is needed in database design? Describe third normal form with an example. [5]
Second normal form
2080 ยท 5 marks
What is Normalization? Explain the 2NF with Examples. [5]
Show solved answerHide answer
Normalization and Second Normal Form (2NF)
What is Normalization?
Normalization is the process of organizing the attributes and tables of a relational database to minimize data redundancy and improve data integrity. It involves decomposing a large table into smaller, well-structured tables and defining relationships between them.
Goals of Normalization:
- Eliminate redundant data
- Ensure data dependencies make sense
- Reduce anomalies (insertion, update, deletion anomalies)
Second Normal Form (2NF)
A relation is in Second Normal Form (2NF) if:
- It is already in First Normal Form (1NF), AND
- Every non-key attribute is fully functionally dependent on the entire primary key (i.e., there is no partial dependency).
Partial Dependency: A non-key attribute depends on only a part of a composite primary key, not the whole key.
Note: 2NF is only relevant when the primary key is composite (made up of more than one attribute).
Example
Table NOT in 2NF
Consider the following relation:
| StudentID | CourseID | StudentName | CourseName | Grade |
|---|---|---|---|---|
| S01 | C01 | Ram | DBMS | A |
| S01 | C02 | Ram | OS | B |
| S02 | C01 | Sita | DBMS | A+ |
- Primary Key: (StudentID, CourseID) -- composite key
- Functional Dependencies:
- (StudentID, CourseID) โ Grade โ (full dependency)
- StudentID โ StudentName โ (partial dependency)
- CourseID โ CourseName โ (partial dependency)
StudentName depends only on StudentID, and CourseName depends only on CourseID. These are partial dependencies, so this table violates 2NF.
Converting to 2NF
Decompose the table to remove partial dependencies:
Table 1: Student
| StudentID | StudentName |
|---|---|
| S01 | Ram |
| S02 | Sita |
Table 2: Course
| CourseID | CourseName |
|---|---|
| C01 | DBMS |
| C02 | OS |
Table 3: Enrollment
| StudentID | CourseID | Grade |
|---|---|---|
| S01 | C01 | A |
| S01 | C02 | B |
| S02 | C01 | A+ |
Now:
- Each non-key attribute is fully dependent on the whole primary key.
- All three tables are in 2NF.
Summary
| Normal Form | Condition |
|---|---|
| 1NF | Atomic values, no repeating groups |
| 2NF | 1NF + No partial dependency on composite key |
2079 ยท 5 marks
What is normalization? Explain 2NF with example. [5]
Quality measures for relational schema design
2079 ยท 10 marks
What is a functional dependency? What are the four informal measures of quality for relational schema design? Explain.[10]
Third normal form
2078 ยท 5 marks
What is Functional Dependency? Explain 3NF with Examples. [5]
Make Unit 5 stick
Practice BIT202 with flashcards & quizzes