You are on page 1of 24

NORMALIZATION

Objective of Normalization
To free relations from undesirable
insertion ,deletion,update anomalies.
To remove inconsistencies
Normalization of data can be defined
as a process during which redundant
relation schemas are decomposed by
breaking up their attributes into smaller
relation schemas that possess desirable
properties.

A relation is said to be in particular normal


form if it satisfies a certain specified set of
constraints.For Eg:
1NF: eliminate repeating groups
2NF: Non-key attribute fully functional
dependence on PK
3NF: Eliminate Transitive dependency on
PK
4NF: remove Multivalue dependency
5NF: Join Dependency

1st Normal Form


A relation is said to be in 1st normal form
if & only if every entry of the relation has
atmost a single value.

Faculty Name

Course_code

harish

CSE301
CSE316
CSE501

Pardeep

CSE302
CSE316
CSE101

RAJ

CSE402
CSE101

To make it in 1NF,we have to use


atomic value:
Faculy_name

Course_code

Harish
Harish
Harish

CSE301
CSE316
CSE501

Pardeep
Pardeep
Pardeep

CSE302
CSE316
CSE101

Raj
Raj

CSE402
CSE101

2nd Normal form


A relation is said to be in 2nd Normal form
if:
1.If it in 1NF
2.All its non-primary attributes are fully
dependent on the primary key.

Consider relation Lab_course


Lab_course

Teacher

Lab_no

Lab_capacity

CSE301

ANIL

33-301

30

CSE304

AMIT

33-302

28

CSE316

SUMIT

33-303

32

CSE101

NIKHIL

33-304

30

CSE501

RAHUL

33-305

28

First find out all the functional


dependencies :
1. Lab_course Teacher

2.Lab_course Lab_no
3.Lab_course Lab_capacity
1 & 2 dependencies exist but 3 does not exist.
As lab_capacity is determined from lab_no ,not
from lab_course.
So this relation is not in 2NF Becoz non-primary
attribute is not fully functionally dependent on
the primary key.

To make it in 2NF,decompose it
into two relations
Lab_course teacher
Lab_course Lab_no
Lab_course

Teacher

Lab_no

CSE301

ANIL

33-301

CSE304

AMIT

33-302

CSE316

SUMIT

33-303

CSE101

NIKHIL

33-304

CSE501

RAHUL

33-305

Lab_noLab_capacity
Lab_no

Lab_capacity

33-301

30

33-302

28

33-303

32

33-304

30

33-305

28

Now these two relations are in 2NF becoz in each


relation all
the non primary attributes are fully functional on
primary key

3rd Normal form


A relation is in 3rd normal form:
If it is in 2NF
All non-primary attributes have no
transitivity dependency on the primary
key

Consider student relation:


rollno

Game

Fee

Cricket

200

Tennis

300

Football

100

Cricket

200

Hockey

150

This relation is in 1NFbecoz all its attribute contain atom


Also it is in 2NF becoz all its non-primary key attributes
functional dependent on the primary key (RollNo).
But it is not 3NF becoz there is transitive dependency.

Rollnogamefee

So Anomalies exist in this relation also


therefore to overcome these anomalies relation is
decomposed into two smaller relations
Game_fee

Student _game

Rollno

Game

Game

Fee

Cricket

Cricket

200

Tennis

Tennis

300

Football

Football

100

Cricket

Hockey

150

hockey

Boyce Codd Normal form


BCNF is an improved form of 3NF.
A relation is in 3NF ,if every determinant is a
candidate key
A determinant is an attribute on which
other attribute is fully functional dependent.

Eg:
RegistrationNo,sectionNocourse_name
SectionNo ,course_IDfaculty_name

4th Normal Form


A relation is in 4th NF:
If it is in 3rd NF OR BCNF
If it contains no multi valued
dependencies. OR there are multi value
dependencies but the attributes which
are multi value dependent on a specific
attribute are dependent between
themselves.

Consider Employee Relation:


case1:
Emp_id

Language

Skill

101

English

Teaching

101

Hindi

Singing

101

Punjabi

Conversation

202

English

Singing

202

Hindi

teaching

Here both employees know more than one language & also have
More than one skill.thus multivalued dependency exists.
Emp_id Language
Emp_idskill
Here, language & skill are dependent becoz for each skill a
specific language is used.
Thus it is in 4NF & does not suffer from any anomaly.

Consider another employee


relation with multi value
dependencies:
Emp_id

Language

Skill

101

English

Teaching

101

Hindi

Conversation

101

English

Conversation

101

Hindi

Teaching

202

English

Singing

202

Hindi

teaching

Here both employees know more than one language & also have
More than one skill.thus multivalued dependency exists.
Emp_id Language
Emp_idskill
Here, language & skill are independent becoz for each skill ,
not a specific language is used.
Thus it is NOT in 4NF & sufferS from DELETE & UPDATE anomaly.

To make it into 4NF,decompose it


into two smaller tables & it will
not suffer from anomaly
Emp_language

Emp_skill

Emp_id

language

Emp_id

skill

101

English

101

Teaching

101

Hindi

101

Conversation

202

English

202

Singing

202

hindi

202

teaching

5th Normal Form


A relation is said to be in 5thNF if:
It is in 4NF
It can not be further non-loss
decomposed.

Consider the table


Agent

Company

Product_name

Suneet

ABC

NUT

Suneet

ABC

Screw

Suneet

CDE

Bolt

Raj

ABC

bolt

This table is in 4NF becoz it contains no multi-valued dependen


but contain a redundancy as Suneet is agent for ABC twice &
there is no way of eliminating this redundancy without informa

Decomposing table into p1&


p2
Agent

Company

Suneet

ABC

Suneet

CDE

Raj

ABC

AGENT

PRODUCT_nam
e

Suneet

Nut

Suneet

Screw

Suneet

Bolt

Raj

bolt

Now redundancy has been eliminated but the information about which
Make which products & which of these products thet supply to which a
has been lost.

Apply Join on P1 & P2 and


resultant table is as follows
named as AgentNew:
Agent

Company

Product_name

Suneet

ABC

Nut

Suneet

ABC

Screw

Suneet

ABC

Bolt*

suneet

CDE

Nut*

suneet

CDE

Screw*

suneet

CDE

bolt

raj

ABC

bolt

The resulting table after join is spurious as asterisked row of tab


contains incorrect information.

Now consider table is


decomposed into 3 parts P1,P2&
P3
P3

Company

Product_name

ABC

Nut

ABC

screw

ABC

bolt

CDE

bolt

Now perform join on AgentNew &


P3
Agent

Company

Product_name

suneet

ABC

nut

suneet

ABC

screw

suneet

ABC

Bolt*

suneet

CDE

bolt

raj

ABC

bolt

This still contain spurious row


So it is not possible to decompose Agent table without losing information
And it has to be accepted that it is not possible to eliminate all redundan
sing normalization becoz it can not be assumed that all decompositions wi