Example Normalization With Solution
Example Normalization With Solution
Problem:
Consider the following table of student information:
Requirements:
Convert the table to 1NF.
Solution:
To achieve 1NF, remove any repeating groups by ensuring that each attribute contains only
atomic (indivisible) values.
Now, each field contains only a single value, so the table is in 1NF.
Problem:
Consider the following table for a book store:
Requirements:
Convert the table to 2NF by eliminating partial dependencies. Assume that (OrderID,
BookID) is the composite primary key.
Solution:
To be in 2NF, a table must be in 1NF, and all non-key attributes must depend on the entire
primary key.
Partial Dependency: BookTitle and Author depend only on BookID, not on
OrderID.
1. Orders Table:
2. Books Table:
Now, each non-key attribute is fully dependent on the entire primary key in both tables,
achieving 2NF.
Problem:
Consider the following table for employee information:
Requirements:
Convert this table to 3NF by eliminating transitive dependencies.
Solution:
To achieve 3NF, the table must be in 2NF, and there should be no transitive dependency
(non-key attributes depending on other non-key attributes).
1. Employee Table:
2. Department Table:
DeptI DeptName
D
D1 HR
D2 IT
3. Manager Table:
ManagerID ManagerName
101 Alice
102 Bob
Now, each non-key attribute is fully dependent on the primary key, achieving 3NF.
Problem:
Consider the following table for student-course enrollments:
Requirements:
Convert this table to BCNF if any anomalies exist. Assume that each course is taught by a
single instructor, but students can enroll in multiple courses.
Solution:
To be in BCNF, the table must be in 3NF, and all non-trivial functional dependencies should
have a superkey on the left side.
1. Enrollment Table:
StudentI CourseID
D
S1 C1
S2 C2
S1 C2
S2 C1
2. Course Table:
CourseID Instructor
C1 Prof. A
C2 Prof. B
Now, all non-trivial functional dependencies in each table have a superkey on the left side, so
the tables are in BCNF.