Normalization 2021 New
Normalization 2021 New
SLIDESMANIA.CO
DFC20083
DATABASE DESIGN
M
Course Outline - Normalization
3.1.1 Define normalization concept
1 3.1.6 Describe the various types of normal forms
6
3.1.2 Describe the purpose of normalization in
database model
2
7 3.1.7 Identify the steps in Normalization process
3.1.3 Explain the importance of normalization in
database c
3
3.1.8 Apply the rule of First, Second, and Third
3.1.4 Define functional dependencies (FD)
8 Normal Form to resolve a violation in the model
SLIDESMANIA.CO
3.1.5 Define transitive dependencies 9 3.1.9 Define Boyce Codd Normal Forms (BCNF)
5
M
○ Minimal redundancy with each attribute represented only once with the
important exception of attributes that form all or part of foreign keys
M
Purpose of normalization
● The benefits of using a database that has a suitable set of relation is that the
database will be:
○ Update to the data stored in the database are achieved with a minimal
c
number of operations which reduce opportunities or data inconsistencies
○ Reduce file storage required by the base relations which minimize cost.
SLIDESMANIA.CO
M
Anomalies in DBMS
● There are three types of anomalies that occur when the database is nor
normalized.
● The anomalies are: c
○ Insertion anomalies
SLIDESMANIA.CO
○ Update anomalies
○ Deletion anomalies.
M
Anomalies in DBMS
● Example:
address and emp_dept for storing the department details in which the employee
works. At some point of time the table looks like this:
M
Anomalies in DBMS
The table is
not normalized
have to update the same in two rows or the data will become inconsistent. If
somehow, the correct address gets updated in one department but not in other
then as per the database, Rick would be having two different addresses, which
M
the data into the table if emp_dept field doesn’t allow nulls.
M
Therefore to overcome
update, insert and delete
Anomalies in DBMS anomalies, normalization is
needed to normalize the data
● Delete anomaly – occurs when certain attributes are lost because of deletion of
other attributes.
c
● Suppose, if at a point of time the company closes the department D890 then
deleting the rows that are having emp_dept as D890 would also delete the
SLIDESMANIA.CO
c
○First normal form (1NF)
9990000123
104 Lester Bangalore
8123450987
First normal form (1NF)
● To make the table complies with 1NF, we should have the data in the tablie like
this.
emp_id emp_name c
emp_address emp_mobile
101 Herschel New Delhi 8912312390
This table is in
102 Jon Kanpur 8812121212
SLIDESMANIA.CO
● An attribute that is not part of any candidate key is know as non-prime attribute
M
Second normal form (2NF)
● Example : Suppose a school wants to store the data of teachers and the subjects
they teach. They create a table that look like this: Since a teacher can teach
more than one subjects, the table can have
c multiple rows for the same teacher.
SLIDESMANIA.CO
teacher_id teacher_age
c
111 38
222 38
SLIDESMANIA.CO
333 40
M
Second normal form (2NF)
Now the tables
comply with
● Teacher_subject table: Second normal
form (2NF)
teacher_id c subject
111 Maths
111 Physics
SLIDESMANIA.CO
222 Biology
333 Physics
333 Chemistry
M
Third normal form (3NF)
● A table design is said to be in 3NF if both the following conditions hold:
attribute.
Third normal form (3NF)
● Example: Suppose a company wants to store the complete address of each
employee, they create a table named employee details that looks like this:
Super key:
{emp_id},{emp_id,
emp_id emp_name emp_zip c
emp_state emp_city emp_district emp_name},
{emp_id,
1001 John 282005 UP Agra Dayal Bagh emp_name,
emp_zip} and so on
SLIDESMANIA.CO
● To make this table complies with 3NF we have to break the table into two
tables to remove the transitive dependency.
M
Third normal form (3NF)
● employee table:
● Emp_dept table:
SLIDESMANIA.CO
Example
SLIDESMANIA.CO
M
Example 1 – (1NF) (Original table)
Unnormalized table
c
Phone number
column has two
values which
violated the 1NF
SLIDESMANIA.CO
rule
M
First normal form (1NF) (Result)
c In this table,
atomicity is
achieved and
every column
SLIDESMANIA.CO
have unique
values
M
Example 2 (Original table) – 2NF
This table has a composite primary key
Employee id and Department ID.
c
SLIDESMANIA.CO
M
Example 3 (Original table) – 3NF
In this table, Student ID determines Subject ID
an Subject ID determines Subject
Therefore, Student ID determines Subject via
Subject ID.
c This implies that we have transitive functional
dependency and this structure does not
satisfy third normal form
SLIDESMANIA.CO
M
Example 3 (Result) – 3NF
In this table, all the non-key attributes are now
fully functional dependent only on the primary
key
In the first table, columns Student name,
c Subject ID and Address are only dependent
on Student ID.
In the second table, Subject is only dependent
on Subject ID
SLIDESMANIA.CO
M
Example 4 (Original table) – BCNF
For this table, one student can enrols in many
subject
○ Primary key
○ Composite key
M
○ Foreign key
Types of key – Primary key
● A primary key is a single column value used to identify a database record
uniquely
○ The primary key must be given a value when a new record is inserted
Types of key – Composite key
● A composite key is a primary key composed of multiple columns used to
identify a record uniquely.
● Example:
c
SLIDESMANIA.CO
In this table, membership ID and full name is the composite key that can uniquely
identify the data. However, physical address only rely on only full name to identify the
address of that particular user. Therefore, in this table, there exist partial dependency
situation.
Summary of First Normal Form (1NF)
rules
● Removes repeating groups from the table
● Higher version 3NF and was developed by Raymond F. Boyce and Edgar F.
SLIDESMANIA.CO
Codd
● Every functional dependency A->B, then A has to be the Super Key of that
M
particular table