Normalization in DBMS
Normalization in DBMS
Anomalies in DBMS
There are three types of anomalies that occur when the database
is not normalized. These are: Insertion, update and deletion
anomaly. Let’s take an example to understand this.
This table is not normalized. We will see the problems that we face
when a table in database is not normalized.
Normalization
Here are the most commonly used normal forms:
First normal form(1NF)
Second normal form(2NF)
Third normal form(3NF)
Boyce & Codd normal form (BCNF)
Example: Let’s say a company wants to store the names and contact
details of its employees. It creates a table in the database that looks
like this:
8812121212 ,
102 Jon Kanpur
9900012222
Two employees (Jon & Lester) have two mobile numbers that caused
the Emp_Mobile field to have multiple values for these two employees.
This table is not in 1NF as the rule says “each attribute of a table
must have atomic (single) values”, the Emp_Mobile values for
employees Jon & Lester violates that rule.
To make the table complies with 1NF we need to create separate rows
for the each mobile number in such a way so that none of the
attributes contains multiple values.
Example: Let’s say a school wants to store the data of teachers and
the subjects they teach. They create a table Teacher that looks like this:
Since a teacher can teach more than one subjects, the table can have
multiple rows for a same teacher.
111 Maths 38
111 Physics 38
222 Biology 38
333 Physics 40
333 Chemistry 40
Teacher_Id Teacher_Age
111 38
222 38
40
333
Teacher_Subject table:
Teacher_Id Subject
111 Maths
111 Physics
222 Biology
333 Physics
333 Chemistry
Now the tables are in Second normal form (2NF). To learn more about
2NF refer this guide: 2NF
To make this table complies with 3NF we have to disintegrate the table
into two tables to remove the transitive dependency:
Employee Table:
Employee_Zip table: