Normalization
Normalization
Normalization is the branch of relational theory that provides design insights. It is the process of
determining how much redundancy exists in a table. The goals of normalization are to:
If a database design is not perfect, it may contain anomalies, which are like a bad dream for any
database administrator. Managing a database with anomalies is next to impossible.
Update anomalies − If data items are scattered and are not linked to each other properly,
then it could lead to strange situations. For example, when we try to update one data item
having its copies scattered over several places, a few instances get updated properly while
a few others are left with old values. Such instances leave the database in an inconsistent
state.
Deletion anomalies − We tried to delete a record, but parts of it was left undeleted
because of unawareness, the data is also saved somewhere else.
Insert anomalies − We tried to insert data in a record that does not exist at all.
Normalization is a method to remove all these anomalies and bring the database to a consistent
state.
Normal Forms
All the tables in any database can be in one of the normal forms we will discuss next. Ideally we
only want minimal redundancy for PK to FK. Everything else should be derived from other
tables. There are six normal forms, but we will only look at the first four, which are:
To normalize a relation that contains a repeating group, remove the repeating group and form
two new relations.
The PK of the new relation is a combination of the PK of the original relation plus an attribute
from the newly created relation for unique identification.
We will use the Student_Grade_Report table below, from a School database, as our example to
explain the process for 1NF.
In the Student Grade Report table, the repeating group is the course information. A student can
take many courses.
Remove the repeating group. In this case, it’s the course information for each student.
Identify the PK for your new table.
The PK must uniquely identify the attribute value (StudentNo and CourseNo).
After removing all the attributes related to the course and student, you are left with the student
course table (StudentCourse).
The Student table (Student) is now in first normal form with the repeating group removed.
The two new tables are shown below.
It defines that all the attributes in a relation must have atomic domains. The values in an atomic domain
are indivisible units.
Second Normal Form (2NF)
For the second normal form, the relation must first be in 1NF. The relation is automatically in
2NF if, and only if, the PK comprises a single attribute.
If the relation has a composite PK, then each non-key attribute must be fully dependent on the
entire PK and not on a subset of the PK (i.e., there must be no partial dependency or
augmentation).
Eliminate all dependent attributes in transitive relationship(s) from each of the tables that have
a transitive relationship.
Create new table(s) with removed dependency.
Check new table(s) as well as table(s) modified to make sure that each table has a determinant
and that no table contains inappropriate dependencies.
See the four new tables below.
At this stage, there should be no anomalies in third normal form. Let’s look at the dependency
diagram (Figure 12.1) for this example. The first step is to remove repeating groups, as discussed
above.
To recap the normalization process for the School database, review the dependencies shown in
Figure 12.1.
In the above image, Stu_ID is the super-key in the relation Student_Detail and Zip is the super-
key in the relation ZipCodes. So,
and
Zip → City
BCNF Example 1
The semantic rules (business rules applied to the database) for this table are:
The functional dependencies for this table are listed below. The first one is a candidate key; the
second is not.
To reduce the St_Maj_Adv relation to BCNF, you create two new tables:
St_Adv table
Student_id Advisor
111 Smith
111 Chan
320 Dobbs
671 White
803 Smith
Adv_Maj table
Advisor Major
Smith Physics
Chan Music
Dobbs Math
White Physics