Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 18

Chapter 8

Schema Refinement and Normal Forms


What is Normalization?
What are the problems and anomalies caused by redundancy?
What is Functional dependency?
What is the difference between full functional dependency and partial dependency?
What is transitive dependency?
What is Multivalued dependency?
What is oin dependency and !ow it is related to "ossless #ecomposition?
What is #omain Constraint?
What is #enormalization?
What are Merits and #emerits of Normalization
$ey %oints & Normalization' Normal forms' Functional #ependency' Full' %artial and
(ransitive #ependency' Multivalued #ependency' oin #ependency' "ossless oin'
#omain Constraints' #enormalization
8.1 LOGICAL DATABASE DESIGN-NORMALIZATION
)n the previous lesson we described lo*ical database desi*n usin* the entity+relationship
dia*rammin* techni,ue- (here are two approaches to lo*ical database desi*n&
(he top+down approach
(he bottom+up approach
(he ./R modelin* techni,ue is the top+down approach- )t involves identifyin* entities'
relationships and attributes' drawin* the ./R dia*ram and mappin* the dia*ram to tables-
Normalization is the bottom 0up approach- )t is a step+by+step decomposition of comple1
records into simple records- Normalization reduces redundancy usin* the principle of
non+loss decomposition- Non+loss decomposition is the reduction of a table to smaller
tables without any loss of information-
Why Normalize
Normalization reduces redundancy- Redundancy is the unnecessary repetition of data- )t
can cause problems with stora*e and retrieval of data- Redundancy can lead to&
I!"o!#i#$e!"ie#
.rrors are more li2ely to occur when facts are repeated-
%&'a$e a!omalie#
)nsertin*' modifyin* and deletin* data may cause inconsistencies-
(here is a hi*h li2elihood of updatin* or deletin* data in one relation'
while omittin* to ma2e correspondin* chan*es in other relations-
Normalization is a step+by+step process of decomposin* a comple1 relation into a simple
and stable data structure- )t3s a formal process to achieve a *ood database desi*n- )t can
also used to chec2 that an e1istin* desi*n is of *ood ,uality- #urin* the process of
normalization' we can identify dependencies' which can cause problems when deletin* or
updatin*- Normalization also helps simplify the structure of tables-
4 fully normalized record consists of&
4 primary 2ey that identifies that entity-
4 set of attributes that describe that entity
8.( Normal )orm#
(he different sta*es of normalization are 2nown as 5normal forms6- Normalization
results in the formation of tables that satisfy certain specified constraints' and represents
certain normal forms- Normal forms are table structures with minimum redundancy-
Several normal forms have identified- (he most important' and widely used of these are&
First Normal Form 78
st
NF9
Second Normal Form 7:
nd
NF9
(hird Normal Form 7;
rd
NF9
<oyee+Codd Normal Form 7<CNF9
Fourth Normal Form 7=
th
NF9
Fifth Normal Form 7%NF9
Si1th Normal Form 7#$NF9
Fi*ure 8-8 & Normal Forms
(o accomplish normalization we need to understand the concept of Functional
#ependencies&
8NF relations
:NF relations
8NF
:NF
;NF
>NN?RM4")@.# R."4()?N
=NF
ANF
BNF
8.* )+!"$io!al De&e!'e!"ie#
)n a *iven relation R' attribute C is functionally dependent on D' if each value of C in R is
associated with precisely one value of D- )n other words&
)n a *iven relation R' D and C are attributes- 4ttribute C is functionally dependent on
attribute D if each value of D determines .D4C("C ?N. value of C' which represented
as &
D+E C
D can be composite in nature that is' it is composed of more than one attribute-
We say here 51 determines y6 or 5y is functionally dependent on 16 D+E C does not imply
C+ED
4ssume after performin* a data analysis' we arrived at the followin* attributes that we
need to store about an entity C>S(?M.R-
Code
Name
4ddress
%hone+number
Fiven a particular value of "o'e' there is precisely one correspondin* value for !ame'
a''re##' and &ho!e-!+m,er- !ence' the attributes !ame- a''re## a!' &ho!e-!+m,er
are functionally dependent on the attribute "o'e-
Now that we 2now somethin* about functional dependencies' let us redefine the concept
of 2eys in terms of functional dependencies- )n the above e1ample of the entity
C>S(?M.R' the attribute "o'e will be uni,ue in every tuple- !ence' it is a candidate
2ey- 4ll attributes must be functionally dependent on the 2ey-
!owever' functional dependency does not re,uire an attribute to be the 2ey in order to
functionally determine other attributes- (he followin* e1ample e1plains this- Suppose we
need to store sales information- (he attributes that we need to store are&
CG & (he code of the customer to whom the sale has been made-
C)(C & (he city to which the shipment is made-
%R?#G & (he code of the product that has been sold to customer-
H(C & (he ,uantity of the product sold to the customer-
Note that the city to which the shipment is made is also the city where the customer is
located- !ence' CG functionally determines C)(C- <ut CG is not a candidate 2ey- (he
candidate 2ey in this case' will be a combination of CG and %R?#G- 4ttributes CG and
%R?#G are the forei*n 2eys that reference the tables that store the customer and product
information respectively- (herefore' even thou*h CG is not a candidate 2ey' it still
functionally determines another attribute 7C)(C9-
CG C)(C H(C %R?#G
C: "ondon =II $:
C= %aris :II $J
C: "ondon =III %=I
C: "ondon KII $J
C= %aris :IB %=I
Fi*ure 8-: & S4". (able
(herefore functional dependency can be described as follows&
8- 4n attribute is functionally dependent if its value is determined by another
attribute-
:- (hat is' if we 2now the value of one 7or several9 data items' then we can find
the value of another 7or several9-
;- Functional dependencies are e1pressed as D C' where D is the determinant
and C is the functionally dependent attribute-
=- )f 4 7<'C9 then 4 < and 4 C-
B- )f 74'<9 C' then it is not necessarily true that 4 C and < C-
A- )f 4 < and < 4' then 4 and < are in a 8+8 relationship-
K- )f 4 < then for 4 there can only ever be one value for <-
8.*.1 Ty&e# o. )+!"$io!al De&e!'e!"ie#
Full functional dependency
%artial Functional dependency
(ransitive dependency
8.*.1.1 )+ll )+!"$io!al De&e!'e!"ie#
Consider the followin* Relation
R.%?R(7SG' SName' CG' C(itle' )name' RoomG' Mar2s' Frade9
SG + Student Number
SName 0 Student Name
CG + Course Number
C(itle+ Course (itle
SG +E Student Number
Sname +E Student Name
)Name 0 Name of the )nstructor who delivered the course
RoomG + Room number which is assi*ned to respective instructor
Mar2s 0 Scored in Course C?>RS.G by the student S(>#.N(G
Frade 0 obtained by Student S(>#.N(G in Course C?>RS.G
Functional dependencies in the previous e1ample are &
SG +E SName
CG +E C(itle
CG +E )name 74ssumin* one course is tau*ht by only one instructor9
)Name +E RoomG 74ssumin* each instructor has his/her own and non+shared
room9
SG'CG +E Mar2s
Mar2s +E Frade
SG' CG +E Frade
#ependency #ia*ram
R.%?R(7S(>#.N(G' C?>RS.G' CourseName' )name' RoomG' Mar2s' Frade9
Fi*ure 8-; #ependency #ia*ram
)f there is a relation R havin* attributes D and C and D functionally determines C- )f D is
a composite attribute then a subset of D should not functionally determine C-
)n above e1ample Mar2s is fully functionally dependent on S(>#.N(G C?>RS.G and
not on subset of S(>#.N(G C?>RS.G- (his means Mar2s cannot be determined either
by S(>#.N(G or C?>RS.G alone- )t can be determined only usin* S(>#.N(G and
C?>RS.G to*ether- !ence Mar2s is fully functionally dependent on
S(>#.N(GC?>RS.G-
8.*.1.( /ar$ial De&e!'e!"y
RoomG
)Name
C(itle
Frades
Mar2s
SName
SG
CG
)f in a relation R' D and C are attributes- 4ttribute C is partially dependent on the attribute
D only if it is dependent on a sub+set of attribute D-
)n the above relationship 7fi*ure 8-;9 Course(itle' )name are partially dependent on
composite attributes S(>#.N(GC?>SR.G because C?>RS.G alone defines the
Course(itle' )name-
8.*.1.* Tra!#i$i0e De&e!'e!"y
)n a *iven relation R' there are three attributes D'C and @- C is functionally dependent on
D and @ is functionally dependent on C- (herefore there is an indirect dependency
between D and @- (his is called transitive 7indirect9 dependency-
D +EC
C +E @
LE D+E@
)n the above e1ample' RoomG depends on )name and in turn )name depends on
C?>RS.G- !ence RoomG transitively depends on C?>RS.G-
Similarly Frade depends on Mar2s' in turn Mar2s depends on S(>#.N(GC?>RS.G
hence Frade depends transitively on S(>#.N(GC?>RS.G-
8.1 )ir#$ Normal )orm
4 relation is said to be in first normal form if all attributes defined on domains containin*
atomic values- Consider the followin* relation- (his relation is unnormalized because
each row contains multiple values-
(he relational model does not permit tables that are unnormalized- )n the relational
model' every relation is in first normal form- !ence' the tables arrived at from the entity+
relationship dia*ram should be at least in first normal form-
Steps for convertin* a database to 8NF&
%ut all double values in separate lines-
.C?#. #.%( %R?C?#. !?>RS
.8I8 SCS(.MS %:K
%B8
%:I
JI
8I8
AI
.;IB S4".S %:K 8IJ
.BI8 4#M)N %B8
%:K
N>""
K:
Fi*ure 8-=& 4n >nnormalized relation
.C?#. #.%( %R?C?#. !?>RS
.8I8 SCS(.MS %:K JI
.8I8 SCS(.MS %B8 8I8
.8I8 SCS(.MS %:I AI
.;IB S4".S %:K 8IJ
.BI8 4#M)N %B8 N>""
.BI8 4#M)N %:K K:
Fi*ure 8-B& 4 relation in first normal form
8.2 Se"o!' Normal )orm
#ata in the tables in 8NF may be redundant- Consider the table in fi*ure 8-B- (his table
stores the followin* attributes&
.C?#. & employee code
#.%( & department to which the employee belon*s-
%R?C?#. & code of proMect on which employee is wor2in*
!?>RS & number of hours wor2ed
(he primary 2ey here is composite 7.C?#. N %R?C?#.9- (he attributes in this table
depends upon only part of the primary 2ey&
%R?C?#. N .C?#. functionally determine !?>RS-
.C?#. functionally determines #.%(- 4ttributes #.%( has no dependency on
%R?C?#.-
(his situation could lead to the followin* problems&
)nsertion
(he department of a particular employee cannot be recorded until the employee is
assi*ned a proMect-
>pdation
For a *iven employee' the employee code and department is repeated several
times- !ence' if an employee is transferred to another department' this chan*e
will have to be recorded in every instance or record of the employee- 4ny
omissions will lead to inconsistencies-
#eletion
)f an employee completes wor2 on a proMect' his/her record will be deleted- (he
information re*ardin* the department the employee belon*s to will also be lost-
(he table in fi*ure 8-B should' therefore' be decomposed without any loss of
information as shown below&
ECODE DE/T
.8I8 SCS(.MS
.;IB S4".S
.BI8 4#M)N
ECODE /RO3CODE 4O%RS
.8I8 %:K JI
.8I8 %B8 8I8
.8I8 %:I AI
.;IB %:K 8IJ
.BI8 %B8 N>""
.BI8 %:K K:
Fi*ure 8- A& Non+loss decomposition 0 (able in :NF
Notice that the ori*inal table can be reconstructed with a Moin-
4 table is said to be in Second Normal Form when it is in First Normal Form' and every
attribute in the record is functionally dependent upon the whole 2ey' and not Must a part of
the 2ey-
(he steps for convertin* a database to Second Normal Form 7:NF9&
)dentify the functional dependencies in the relationO
)dentify attributes that are dependent only to a part of 2ey 7partial dependency9
Remove partial dependencies by placin* them in new relations to*ether with a
copy of determinant-
8.5 Thir' Normal )orm
4 table is said to be in ;NF when it is in :NF and every non+2ey attribute is functionally
dependent on Must the primary 2ey- For e1ample' consider the fi* A-=- (he primary 2ey is
.C?#.- (he attribute #.%( is dependent on .C?#.- (he attribute #.%(+!.4# is
dependent on #.%(- #.%(+!.4# is the code of the department head- Notice that there
is a transitive dependence between .C?#. and #.%(+!.4# attributes-
ECODE DE/T DE/T-4EAD
.8I8 SCS(.MS .JI8
.;IB S4".S .JIA
.=I: S4".S .JIA
.BI8 4#M)N .JI8
.AIK F)N4NC. .JIJ
.AI8 F)N4NC. .JIJ
Fi*ure & 8-K (able With (ransitive #ependency
(he problems with transitive dependency are&
)nsertion
(he department head of a new department that does not have any employees as
yet cannot be entered- (his is because the primary 2ey is un2nown-
>pdation
For a *iven department' the department head3s code is repeated several times-
!ence' if a department head is moved to another department' the chan*e will have
to be made consistently across-
#eletion
)f a particular employee record is deleted' the information re*ardin* the head of
the department will also be deleted- !ence' there will be a loss of information-
(he relation is therefore' reduced to the followin* two relations&
.C?#. #.%( #.%( #.%(+!.4#
.8I8 SCS(.MS SCS(.MS .JI8
.;IB S4".S S4".S .JIA
.=I: S4".S 4#M)N .JI8
.BI8 4#M)N F)N4NC. .JIJ
.AIK F)N4NC.
.AI8 F)N4NC.
Fi*ure 8-8 Removin* (ransitive #ependency
.ach non+2ey attribute depends on the 2ey' the whole 2ey and nothin* but the 2ey-
8.6 Boy"e-Co'' Normal )orm
(he ori*inal definition of ;NF was inade,uate in some situations- )t was not satisfactory
for relations that&
!ad multiple candidate 2eys' where
(hose candidate 2eys were composite
(he candidate 2eys overlapped 7had at least one attribute in common9-
!ence' a new normal form 0 the <oyee+Codd Normal Form 7<CNF9 was introduced- We
must understand that in relations where the above three conditions do not apply' we can
stop at the third normal form- )n such cases' ;NF is the same as <CNF-
"et us e1amine <CNF in detail- Consider the table in fi*ure 8-A- (he relation %R?.C(
holds details on the number of hours spent by each employee wor2in* on each proMect-
.C?#. .M4)")# %R?C?#. !?>RS
.8 vinodMhaPyahoo-com %: =8
.8 vinodMhaPyahoo-com %B 8II
.8 vinodMhaPyahoo-com %A 8B
.= sushil2a2arPyahoo-com %B :BI
.B sushil2a2arPyahoo-com %B KB
Fi*ure 8-J %R?.C( table
Notice the followin* dependencies in this relation&
(he attributes .C?#. and %R?C?#. functionally determine !?>RS-
(he attribute .M4)")# and %R?C?#. also functionally determine determines
!?>RS-
.C?#. functionally determine .M4)")#
.M4)")# functionally determine .C?#.
Notice that this relation has&
Multiple candidate 2eys-
(he candidate 2eys are composite
(he candidate 2eys overlap 0%R?C?#. is common-
(his is a case for the <oyce+Codd Normal Form- (his relation is in ;NF- (he only non+
2ey item is !?>RS' and it is dependent on the whole 2ey and only the 2ey' i-e-
%R?C?#.N.C?#. or %R?C?#.N.M4)")#- !owever' this relation has
redundancies- )f the emailed of an employee is chan*ed' the chan*e will have to be made
in every tuple of the relation' otherwise inconsistencies will creep in- (his table needs to
be further decomposed to eliminate dependence between the candidate 2ey columns-
Fi*ure A-J illustrates the non+loss decomposition of the table in fi*ure 8-8I
.C?#. %R?C?#. !?>RS .C?#. .M4)")#
.8 %: =8 .8 vinodMhaPyahoo-com
.8 %B 8II .= sushil2a2arPyahoo-com
.8 %A 8B
.= %B :BI
.= %B KB
Fi*ure 8-8I & Non+loss decomposition of %roMect table in <CNF-
8.7 )o+r$h Normal )orm
4 relational table is in the Fourth Normal Form 7=NF9 if it is in <CNF and all
multivalued dependencies are also functional dependencies-
8.7.1 M+l$i0al+e' De&e!'e!"y
Multivalued dependencies arise when a relation R havin* a nonatomic attribute is
converted to a normalized form- For .ach D value in such a relation' there will be a set of
C values associated with it- (his association between the D and C values does not depend
on the values of the other attributes in the relation-
4 Multivalued dependency occurs when in a relational table containin* at least three
columns' one column has multiple rows whose values match a value of a sin*le row of
one of the other columns-
8- 4nomalies can occur in relations in <CNF if there is more than one multi+
valued dependency-
:- )f 4 < and 4 C but < and C are unrelated' ie 4 7<'C9 is false' then we
have more than one multi+valued dependency-
;- 4 relation is in =NF when it is in <CNF and has no more than one multi+valued
dependency-
4 table is in Fourth Normal Form 7=NF9 if and only if it is in <CNF and contains no
more than one multi+valued dependency-
(a2e the followin* table structure as an e1ample&
INFO(employee#, skills, hobbies)
(a2e the followin* sample data&
Em&8 S9ill# 4o,,ie#
8:8 %ro*rammin* Folf
8:8 %ro*rammin* <owlin*
8:8 4nalyst Folf
8:8 4nalyst <owlin*
8:: Mana*ement Folf
8:88 Mana*ement Fardenin*
Fi*ure 8-8J )NF? table with Multivalued #ependency
(his table is difficult to maintain since addin* a new hobby re,uires multiple new rows
correspondin* to each s2ill- (his problem is created by the pair of multi+valued
dependencies .M%"?C..G S$)""S and .M%"?C..G !?<<).S- 4 much
better alternative would be to decompose )NF? into two relations&
#9ill#:em&loyee8- #9ill#;
ho,,ie#:em&loyee8- ho,,ie#;
.mpG S2ills .mpG !obbies
8:8 %ro*rammin* 8:8 Folf
8:8 4nalyst 8:8 <owlin*
8:: Mana*ement 8:: Folf
8:: Fardenin*
Fi*ure 8-:I Removin* Multivalued #ependency from )NF? table
8.1< )i.$h Normal )orm ::/ro=e"$io!-3oi! Normal )orm ;
4 table is in Fifth Normal Form7BNF9 or %roMect+oin Normal Form 7%NF9 if it is in =NF
and it cannot have a lossless decomposition into any number of smaller tables-
4nother way of e1pressin* it is &
4 table is in Fifth Normal Form7BNF9 or %roMect+oin Normal Form 7%NF9 if it is in =NF
and there are no pairwise cyclical dependencies in the primary 2ey comprised of three or
more attributes-
BNF is based on the concept of Moin dependence + if a relation cannot be
decomposed any further then it is in BNF-
4nomalies can occur in relations in =NF if the primary 2ey has three or more
fields-
%airwise cyclical dependency means that&
o Cou always need to 2now two values 7pairwise9-
o For any one you must 2now the other two 7cyclical9-
8.1<.1 3oi! 'e&e!'e!"ie#
So far we have focused on the decomposition of a relation scheme with undesirable
properties into two relation schemes such that the decomposition is lossless- 4 Moin of
these decomposed relation schemes will *ive the ori*inal schema and' hence' the data- )n
some cases it may not be possible to find a lossless decomposition of a relation schema
into two relational schemas' the same relation schema can be decomposed losslessly into
three relation schemes- (his property is referred to as the Moin dependency 7#9-
8.1<.( Lo##le## 3oi! a!' De&e!'e!"y-/re#er0i!> De"om&o#i$io!
4 relation scheme R can be decomposed into a collection of relation schemes to eliminate
some of the anomalies contained in the ori*inal relation scheme R- (he lossless Moin
decomposition enables any relation to recovered from its proMections or decomposition by
a series of natural Moins- Such decomposed relations contain the same data as the ori*inal
relation- 4nother property that the decomposition of a relation into smaller relations must
preserve is that the set of functional dependencies of the ori*inal relation must be implied
by the dependencies in the decompositions-
Consider the relation S(>#.N(Q4#R)S?R7Name' #epartment' 4dvisor9 with the
functional dependencies FSName+E#epartment' Name+E4dvisor' 4dvisor+E#epartmentT
(he decomposition of S(>#.N(Q4#R)S?R into S(>#.N(Q#.%4R(M.N(7Name'
#epartment9 and #.%4R(M.N(Q4#R)S?R7#epartment' 4dvisor9 -
S(>#.N(Q4#R)S?R
Name De&ar$me!$ A'0i#or
ones Comp Sci Smith
N* Chemistry (urner
Martin %hysics <os2y
#ulles #ecision Sci !all
#u2e Mathematics ames
ames Comp SciU Clar2
.van Comp Sci Smith
<a1ter .n*lish <ronte
Fi*ure 8-:8 S(>#.N(Q4#R)S?R (able with oin #ependency
S(>#.N(Q#.%4R(M.N(
Name De&ar$me!$
ones Comp Sci
N* Chemistry
Martin %hysics
#ulles #ecision Sci
#u2e Mathematics
ames Comp SciU
.van Comp Sci
<a1ter .n*lish
#.%4R(M.N(Q4#R)S?R
#epartment 4dvisor
Comp Sci Smith
Chemistry (urner
%hysics <os2y
#ecision Sci !all
Mathematics ames
Comp SciU Clar2
.n*lish <ronte
Fi*ure 8-:; "ossy decomposition of S(>#.N(Q4#R)S?R (able
(he Moin of these decomposed relations contains tuples that did not e1ist in the ori*inal
relation7Shown as hi*hli*hted rows9- (he decomposition is called lossy-
Name #epartment 4dvisor
ones Comp Sci Smith
ones Comp Sci Clar2
N* Chemistry (urner
Martin %hysics <os2y
#ulles #ecision Sci !all
#u2e Mathematics ames
ames Comp Sci Smith
ames Comp Sci Clar2
.van Comp Sci Smith
.van Comp Sci Clar2
<a1ter .n*lish <ronte
Fi*ure 8-:= S(>#.N(Q4#R)S?R (able with e1tra tuples after Moin
(herefore we need to divide the ori*inal relation into three relations&
8- Relation8 & Name ' #epartment
:- Relation :& Name' 4dvisor
;- Relation ; & #epartment ' 4dvisor
8.1<.* /air?i#e "y"li"al 'e&e!'e!"ie#
(a2e the followin* table structure as an e1ample&
,+yi!>:,+yer- 0e!'or- i$em;
(his is used to trac2 buyers' what they buy' and from whom they buy-
(a2e the followin* sample data&
<uyer Rendor )tem
Sally "iz Claiborne Shirts
Mary "iz Claiborne Shirts
Sally ordach eans
Mary ordach eans
Sally ordach (rousers
Fi*ure 8-:B /air?i#e "y"li"al 'e&e!'e!"ie#
(he ,uestion is' what do you do if Claiborne starts to sell eans? !ow many records
must you create to record this fact?
(he problem is there are pairwise cyclical dependencies in the primary 2ey- (hat is' in
order to determine the item you must 2now the buyer and vendor' and to determine the
vendor you must 2now the buyer and the item' and finally to 2now the buyer you must
2now the vendor and the item-
(he solution is to brea2 this one table into three tablesV
<uyer+Rendor
<uyer+)tem
Rendor+)tem-
8.11 Domai! @ey Normal )orm
4 relation is said to be in #$NF if all constraints and dependencies that should hold on
the relation can be enforced simply by enforcin* the domain constraints and the 2ey
constraints specified on the relation-
i9 W$eyW means both primary 2eys and candidate 2eys
ii9 W#omainW means the set of definitions of the contents of attributes 7columns9 and any
limitations on the 2ind of data to be stored in the columns' such as a limitation to only
numeric data or only lo*ical dataV in addition' domain limitations may include such
matters as the format 7e-*-' a limitation on numeric data to bein* e1pressed to e1actly two
decimal di*its9-
iii9 WConstraintW means any rule dealin* with attributes that is clear enou*h so that one
can decide whether the rule is upheld or bro2en by any set of the data with which one is
dealin*-
!owever' unli2e the other normal forms' #$/NF is not defined in terms of F#s' MR#s'
#s- (he central re,uirements of #$/NF are the basic concepts of domains' 2eys and
*eneral constraints-
For a relation in #$NF' it becomes very strai*htforward to enforce the constraints by
simply chec2in* that each attribute value in a tuple is of the appropriate domain and that
every 2ey constraint on the relation is enforced-
8.1( De!ormaliza$io!
(he end+product of normalization is a set of related tables that comprise the database- )n
the interests of speed of response to critical ,ueries which demand information from
more than one table' it is sometimes wiser to introduce a de*ree of redundancy in tables-
Sometimes it is important to save dis2 )/?' and C%> time- (he intentional introduction of
redundancy to a table' to improve performance is called denormalization-
For e1ample' if the ,uery 5display the names of all students who ta2e a course in
database desi*n6' 7or for any other course9 is a common one' it would be advisable to
maintain the course information in the same table as shown in fi* A-8- ?therwise' every
time such a ,uery is made' a Moin will have to be carried out on the two tables- For the
sa2e of performance' some redundancy has been introduced in the database-
S(>#.N(G N4M. S(>#.N(G C?>RS.G
S(>#.N(G N4M. C?>RS.G
Fi* 8-:A #enormalization of tables
8.1* Meri$# a!' Demeri$# o. Normaliza$io!
8.1*.1 Meri$# o. Normaliza$io!
89 Normalization is based on mathematical foundation
:9 Removes the redundancy to *reater e1tent- 4fter ;NF' data redundancy is
minimized to the e1tent of forei*n 2eys-
;9 More efficient database structure
=9 <etter understandin* of your data-
B9 More fle1ible database structure
A9 .asier to maintain database structure
K9 Removes the anomalies present in )NS.R(s' >%#4(.s and #.".(.s-
8.1*.( Demeri$# o. Normaliza$io!
89 Cou can3t start buildin* the database before you 2now what the user needs-
:9 #ata retrieval of S.".C( operation performance will be severely affected-
;9 Normalization mi*ht not always represent real world scenarios
S>MM4RC
o Normalization is the bottom approach of lo*ical database desi*n- )t is a
step+by+step decomposition of comple1 records into simple records
o Normalization reduces redundancy- Redundancy can lead to
inconsistencies as well as )nsertion' updation and deletion anomalies-
o (he different sta*es of normalization are 2nown as 5normal forms6--
(he most important' and widely used of these are&
First Normal Form 78
st
NF9
Second Normal Form 7:
nd
NF9
(hird Normal Form 7;
rd
NF9
<oyee+Codd Normal Form 7<CNF9
Fourth Normal Form 7=
th
NF9
Fifth Normal Form 7%NF9
Si1th Normal Form 7#$NF9
o )+!"$io!al De&e!'e!"y& )n a *iven relation R' attribute C is functionally
dependent on D' if each value of C in R is associated with precisely one
value of D-
o )+ll .+!"$io!al 'e&e!'e!"y& )f there is a relation R havin* attributes D
and C and D functionally determines C- )f D is a composite attribute then a
subset of D should not functionally determine C
o /ar$ial )+!"$io!al 'e&e!'e!"y& )f in a relation R' D and C are attributes-
4ttribute C is partially dependent on the attribute D only if it is dependent
on a sub+set of attribute
o Tra!#i$i0e 'e&e!'e!"y& )n a *iven relation R' there are three attributes
D'C and @- C is functionally dependent on D and @ is functionally
dependent on C- (herefore there is an indirect dependency between D and
@- (his is called transitive 7indirect9 dependency-
o )ir#$ Normal )orm :1
#$
N);A4 relation is said to be in first normal form if
all attributes defined on domains containin* atomic values
o Se"o!' Normal )orm :(!' N);&4 table is said to be in Second Normal
Form when it is in First Normal Form' and every attribute in the record is
functionally dependent upon the whole 2ey' and not Must a part of the 2ey-
o Thir' Normal )orm :*r' N);& 4 table is said to be in ;NF when it is in
:NF and every non+2ey attribute is functionally dependent on Must the
primary 2ey-
o Boyee Co'' Normal )orm:BCN); & )f all determinants are candidate
2eys than relation is in <CNF-
o M+l$i0al+e' De&e!'e!"y &4 Multivalued dependency occurs when in a
relational table containin* at least three columns' one column has multiple
rows whose values match a value of a sin*le row of one of the other
columns-
o )o+r$h Normal )orm :1
$h
N);A4 relational table is in the Fourth Normal
Form 7=NF9 if it is in <CNF and all multivalued dependencies are also
functional dependencies
o 3oi! De&e!'e!"y a!' Lo##le## 3oi!& (he lossless Moin decomposition
enables any relation to recovered from its proMections or decomposition by
a series of natural Moins- Such decomposed relations contain the same data
as the ori*inal relation-
o )i.$h Normal )orm ::/ro=e"$io!-3oi! Normal )orm ;4 table is in Fifth
Normal Form7BNF9 or %roMect+oin Normal Form 7%NF9 if it is in =NF
and it cannot have a lossless decomposition into any number of smaller
tables-
o Domai! @ey Normal )orm:D@N);A 4 relation is said to be in #$NF if
all constraints and dependencies that should hold on the relation can be
enforced simply by enforcin* the domain constraints and the 2ey
constraints specified on the relation-
o De!ormaliza$io!A (he intentional introduction of redundancy to a table'
to improve performance is called denormalization-

You might also like