You are on page 1of 203

Scanned with CamScanner

Scanned with CamScanner


Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
, ,.. 1.
: t ·

-.
CH!t-t'/t:t~"t - ~ - - - - - -
"
r... ObJectives ·of Normaliz.,a.. ., ion
.~·
1· :
....
' . ( The basic objective of logical modeling
. . .
is to develop a 11good 11 description ·of the.
-·~ ..
it.'i relationships, and lts constraints. For da~a, ·
the ·relational model 1 this means that we mu· 7
i~<mtify a suitable set of rela tio~ ) How st
ever, ·the task of choosing the relations
d1(6cult one, because th.ere are many opti ' is~·
ons for the designe~ to consider. This
is _devo ted to explaining some met chapter
hods of improving logk'al design.
presented here are based on a large· body The tech niqu ~
of research Into the logic.al design pro
~~ncrally called norm alization. ·
c~
~ 1Ee_p~~~7:cj.:-nq~al_h:~tlon_!s ~2 produ.sf! -~--~ !'le . · 1 ·
_rriodel.Qlthe...or,~.lfili.Qru 9(.tl)e sec_ t:f_~;.~~~o~~.!Ll~.a.Jair:h~I
~Q~Cn?r_is_e.(By.fpllp_wJng.ilie pnn cipl ~_.o
~~-=~ a~~~c a d~~E-~1ia~}s h~ghly fl1:~i~l:s.! f x:io_i:t?a!ii.,ati_on, ·
m:e dcd to acco unt for new attributes, ~!~~-~[}g the_ model,.t~ b~.~t1:,nded wfi.cn,
enti ty sets, and relationships,_ We can
[eclundancy in the database and t.nsUrc tlm also reduce' ·
the design is.free of cert ain upd ate, inse
and dele tion ano mal i~. An ano ~ly rtion,
state is -~ incoruistent,
of the diltab~c. 'ff'iliese anomalieswerc incompl~c;,· or conc raclicto ~-
someinformatioii:wemight l~se inf~;ma ce
··presefii:',wewouli:l un'a blet o reprc .sen .,
tion wh~~-i~--tipdac;w
wl!-;;;~ld. r·u-;;·th~ ;isGf having data-b;come'fnconi'i"stcnto_yer. ;;~ p~rfoi,;:ed, and.
. Research"i"nto iheseanomalies·was·first ~im ~t' --. -·· •~ ·
defined the first three "normal forms".
ao·n ;by Codd, who Identified the causes ~q•
~~ is in IL_specific_,;ionn
satisfies the ~ t ~.f. Jcq uir~ ~~i (1µ
_f9 uh~ t...f m:m .• Not e that the cons
al.fo_ ·· :~t
Wl!-di_scussarc schema corucraints, pen nan train ~
cnt properties of the relation, not mere
some instance of the. relation. Late lf,C!~
r r~ea rch by B0yce and Cod d led
of the third of thes_e forms . Add itional co a telinemet}t
research by Fagin/and indepcndendy by
;• resulted in the definition of three new Zani.olo
normal forms.l_AU of the normal forms•are
ncsred, ig_th~L OO ..l@ @e.s the cons
traints of the previous <?_!}~~-tj~ a__'~
bec aus e eac.h_c_li.ti:1i~1a.tc.dla·tx.d oun b"etter1 fo · •
d in the. previous form. Flgure 7.1 show
sev en normal forms arc related. Toe· s-how·,th"e
largest clrd~ represcnt5 all relatloru. Am
set of all relations those that are in fuse ong the
normal form arc represented by the next
circle. Of those in first normal form, -largest
ther e are some that qualify as seco
form as well; these fall into the nex
t circle, and so on. O~r .d'5 ign obje
nd nonri~I
be to put the schema in the hi~hest norm ctiv e sho~ld
al form that is prac tica l and app ropr iate
the app lica tion . ~o ~a l~t_(o~'. -~~ £~: ·
Jl~i ~g. !_~ :?~~ -~n }_? . a_!:i_~~e~ n~tm
Alth oug h there is still a·~rcat deal of rese
arch being don e on i:hls process, the al ~ ·:~
form, domain-key normal form, is the "fina last no · ~
l" one in a· sense which we will discuss later
Normalization requires that we have a .. _
clear grasp of the semantics of the applicati
on.
Merely examining an instance extensio
not provide enough infonnation
or n. is nor sufficlmt, because an instance
docs ,;. _
about all the possible values or combina
for relation attributes. tions of va~ues .
· "· ( ln :ittcmpting to pinpoint the caus ·
es of update, insertion, and delcclon anom .,-~ .
rc:-c.1.rchccs have identified three importa all~,~'
nt kinds of dependencies: f~~2!1.alA.~
.. den~iis multivalued dependencies and en~- ·,
r-· app'.ear'"fu th; res;"ich join dependenc.iesJ Additional depc
7,ceratuie:--- -- -- -- -- -- '-- ndeni:lcs ·
~- _. ~·-'
·.:•
' •!
7.Z Functional Dependency 223 .. ~

•:,.:,
rif~'. '.,
1Jii1•:,
~t~·1;j:
,\,
Hl•1:1
_;;.:,. ; ,
_:.';Tr (.
:};)'
',:/: ·,
!i_fnl
;rr,.,
: •~ ' • : , t
':!'),I '
,.;
)il..1:-11
' •

¥,~A.-'
i;(;;.ir,
·(; rJt..:,w·
4 ,
;.i} . .
:~
. f,f .
,,:J, •
•,,4,j.A
.; .
.
/J4;'"1
I••
·

))Jr; ;
.:~··w Figure 7.1 ·

· ..? dfunctional Depen~ency


-~.. . . .-
f ff..f!i!.1c_tl~f!A1-~~P.eri~.e11cy_{EQ)_!s a -~pe of r~Ia;~oz:ishiJJ,~~..:E_tdbu,t_
: s~~- -·~ ~?) as d~cribed
~i;f in the following definition: , . · :.
~~· .
·m:-if.·-· Definition o{Functional Dependency
.

~ON: (If A and S are attributes or sets of attributes o~ relation R, we sny that B is fu.nctionaliy
;. dependent on A if.each· value of A Ln R. has associated with it exactly one ..vnlue of B ... •·
:· inR.> ' . . -~ -7 b . . . .
f{ !"-:. '~ t •· .., •. "
ns,. :!fc write this a/ ~ ~ B, ',i:cad ~ ~ A.~io~lly deter:m.in_ e,s ..B"~ ~r ~ ?=~~1:1:1!~
7~ a;~: )
(Note: If we wane to be very explicit ~bout which relation we are discussing, po.ttlcularly
in the case where A or B appears in another relation, we write the qualified name~, ns
'·. .• in R.A -t R.B.'( This does not mean that A causes B or that the value of B can be it .
:\ calculated from'the value of A by a formula, although sometimes that is the cose. It
•,. · simply means that if we know the value of A and we examine the table of relation R,
.~.. we will fin~.rily_one xn,lue. of_f3 inall the rows that have the given value of A at .iny
'· on~ time. Thus when two rows have the same A value, they trtust also have the same: · ·
}.~... B value. However, for a glven 8 value, there may be several different A values. -Whet),
1~\,.·-··.
~~(~• · ·
a, ~c~~~a1~ ~ ~~exist:s, the attribu~~ ~f.a!_t:r~~t~ .':? ~e l:f.:.!!.?~.,~-f t~., .~
_,:_rro~ IS ca11:ca a ceterm:ihm i:r::--- , · ·
~!t .· •:.
. .._:. .. ~
, !;
!;•:
, .
•'..>
'• ,

•.'
,.
•~

:. J'
·l
~LL4 -~-fo rmal izati
~on 7""' ~ - - - - - : :
- : - -
-- ;.·•,. ' ·~l
~
ider the following relation:
• To i?luscrare funcc ional dependency, let u.s cons
\'
STODENT csro10 , sTONAMt, MAJO
R, cru:o ITS, STATtJS ,
5 0C'::~0L /
- • - - __,,,_ --
- -
->._ .. - -·-- -
; ..,._.,. ••• , - - . ·

i_n· a college. Here, :e will a.5surne that~ .


This relation stares information about s~udents
every student has n uniq ue ID and social security number and tha .. each
stud~nt h.a~.J
are not unique, so that two d1fferen~.i
ac most one major. We. wiH assume chat names
s the number of credits completed,;
students may have che same name. CREDITS me;m ·
and STA TIJS refers to the year the stud
ent is in-f resh man , sophomore, junior, orj.
·:..
senior. to help.' "
. Although we will U5 e this inst ance
· Figure 7.2 shows an instance of the table char acteristi c,
g co derc rrnine perm anen t
us dececc functional dcpe nden des, we are cryin tha t if we are ·r
ining the tab[e, we see
of the rc!nrion, not simply of the instance. Exam with t
give n a ~pedfic value of STUID, chere is
only one value of STUNAME asso ciate d
NA ME is . .·
t:h o.c particular STUIO. For examplet for STUID S1006, the associated STU
the relation;, .
that this 'is a char acreristi c of
Lec,:nmela. We know from our assumptions
tionally depende nt on STI JID , and we ·
not Jus_t of this instance, so STUNAME is func .,,.B
:.1-:' .
can wnte :~t\,
- - ·- - \ ·.,~ ~
lsToro -+_ !._ ~_\. • ~"

may be more than .one STIJID. We no~


However, for a given value ofS1DNAME there ·
that for the STUNAME Jones,Marytiona there arc cwo STUID values S 00 . and SH)f>O,,:
l depend d cl, 1 3
The refo re we cann ot tum the func ency aroun an wnt e STUNAM~ ~·
-+ STU
JD• For each of the othe r attributes ' uu: ·I5 on ly one value assoc· ed ·m .d
-L re
w, .~
. l I
pamcu ar va ue of..STUID, so all the attributes arc funccio ll dependent iat on STUlD;,
We wrice • · na Y
.
~ f•
.

soe::"\_j
~- _: _:.~~:__.;:~::.:::~~ ..;;~,--
·, __
· ·· '
the righ t is func tio 11 d
to indi cate that each of the attributes on na Y cpcn dcnt on STIJ ..

\=~o- , we have , ·
Similarly

~~I~-~~~; = ~,;_,,J
t on CREDITS F ·i~
Also note chat STATUS is functionally dependen
TUS is autornatica~t =p ie. ~ di_
va!uc of CREDITS is known to be 15, the STA

~I~:;T:u~_j
wnre ·- Y
· hman..,:.,Wi
. .
since two freshmen may h : ,·~,.
However, we caM ot write STATUS -+ ~I TS , S1060. Fo ~:~ Jif ~
ferenc numberof credits. as we see in the records of S1006 and
S does not functionally dcte · . -,-.,
functional dependency1 the dete rmin ant CREDIT
the other atcributes o~ the relation. Note also
that the V3lue of CREDITS is no~~~
its, uniq ucn ~ .
same number of cred 50
sarily unique. Several scudenrs could have the
. The inscanc.e ln Figure 7.2 did not r~l
not a necessary characteristic of determinants
..
•• '

7.3 Supcrkeys, Candidate Keys, ~na Primary Ke:1s' 225


ISTUIDISTUNAM£ !MAJOR ICREDITSISTATUSISOCSECNO I
1-----1------------ /-------1-~---~-1------1-------- I
ISlOOlJSmith,Tom I.Historyl90 !Sen 1100429500!
:t'~
!JF.• . 1-----1------~ ----1-------1-------1------,---------1
1S1003JJones,Mary !Math 195 .. !Sen 10101245671
I '•jr:
1-----1----------- ✓ 1-------,-~-----1------1---------1
tir IS1006fLee,Pamela' ICSC )15. !Fresh 10885200761
hl1 ·
..__ 1-----1----------._ r-------r-------1------1---------1
!) 1:,: . 1S10101Burns,Edward 1Art !63 JJun 10993209 851
' ,
UH,
i •
:i:Jf:
1-----1---·-------~J---·
I Sl0G0 I Jones, Mary J CSC
---1--
125
.---- J------1--------- 1
I Fresh I 0.64 62 4 7 3 e I
I

------------------ ----------------------------------
\11tl' , FJgure 7.2 STUDENT Table (Each student has al most one major)

demonstrate the lack of uniqueness of CREDITS, which shows that we must be c~n:ful
in making jud&ments from instances only. ·we need to concentrate on the meaning:. of
the attributes and their constra ints in identifying functional dependencies.
; .
)
,.
,.: \_,/'"

fl] Superkeys, Candidate Keys, an~ Pr~mary Keys


,
..~-,
;. Recall from Chapter 5 that a superkey is an attribute OUL~~t.of..atttibutes..that..idi?ntifres.__.
\ •
~ ~.ti.t;I__uI}.iql!ttlY., In a_~a.bl~~crkey is an~qlE,t'~P.-~.S ~..El~o!urons .whtise...,.,,,
..
l

J
· values can be used to d isti.T'1guish one row from another. Since -a superkey idi:ntilies
.. ~ch entity uniquely_ it-~tlonally d~t~;;,l~es-·an °th'e~ttrlhutes of a rclacion.~f:QL
.,!~c. ~ D~J-~-~JD_qgure 7.2.,~1},JJ.!2..iu..!i~P.,er~~Y.:.. So is the cornbinatlo_n of
{STUID,STUNAME}. In fact, {STUID,any ocher attribute} is a superkey for •this
relation. The same L,; r:rue for {SOCSECNO,any other attribute}. · ·
b.~<:a~djdate ke!._!s ~~-petey.:..5;1gi_~r..no.proper...subset _of ~ts_a_ttr_ipu~es_is. i~cl( n'.,__,
supe_r~ey. Jnerefore, a ca.."1di ate key must be a minimal identifier. In our example, the
superkey {S1UID,STIJNAME} . is not a candidate key because it contains a proper
1- subset, STIJID, that is· a superkey. However, §..TIJID by itself is a cnndid:ite k(:y. ·,
I ~milarly, SOCSECN'.) Is a candidate key. !f.E.o two stua~:,!~~e_.Penni,t.tec(to hn.;; the_.:.·
~f!l~l1Jbinacion of ~ame and ma;or v~es, ~e _:o~bi!:1~~01;_{~~~E,MAJOit} ~
~ -19;.a.~ _ke a ,ca~d.~.t~J{~y.:..A relatton maynnve several cnnctidate keys:· We,vill"
use the term •~2!!1P9!}.t~.. kei'.. to J~e.r.,.;o a_,ke_y ~~~F. ~e95is_ts.of_mor~.•t\1a,n_one_nttribute.
We will also drop the set brackers In showing secs of attributes. · .
~.P.r:i~aty...kruu....can9_idatLk~y_that,is. used ..to)de;:ttlfy tuples in a relation.) In
,:n, . . our example, STI.JlD might be the primary key and SOCSl:CNO-~i'naltemacikcY.· ,
.. ,. These two attrilrureshintcionaTlyaecerm1iif' each" oi:ner7""ano-a1Cof ch;· attrib-~te; nr~--·
:,;j,. . _ . functionally dependent~ each of them( ~tho.ugh not explicitly st1;m:d ln the definition,
~~; , ~ - an important charactt-ristic of a primary ~Y,.!!. ~none of its_a,~~tcs may_hnv~!!_
/ ,. · u - (l ~cs) If we permitted null values in keys, we would be unable to tellrccords a~~rt,
•,} · 1/ since rwo records with nu11 values In the: same key ~eld mlghc be lndistlnguish.:i~le.: le
r, · is aJso desirable to enforce die·11 00 nulls" rule for··candidnte keys. •··
J·t.~·
, , . ·,"'t
., •:. .:;~;·
)'

c:; .. 7.4 Inference Rules ·7.27

set of attributes, A, in Fi. We cait this set of attributes the closure of A or A+)Cleoriy, ·
if A+ is all of R, then A is-a superk~y for R. We could-find A+bycomputing· all of F+
and then choosing only those functional dependencies where A ts the decemrimmt, hue
there is a shortcut. The following algorithm can be used to find A+, given a set F of
functional dependencies: ·

2:• ault : • A:
•hila (result changes) do
for ee.ch functional dependency 8 --+ C in F
if B is contained in result then result :a ro11ultl.J C:
end;
A+ :.. reaul.t;

For example, let R be a relation with attributes W, X, Y, Z an d funccional dependencies

yz-x
WZ-+ y

Let us compute wz+: We assign WZ to the result and enter the while for the fir~t
time. We look for an FD whose determinant is contained in result, which has only WZ
at the momenc. The FD wz.
--+ Y satisfies this requirement, so weassign WZ U Y to
result. Since we had a change in result, we enter the while again. Now we look for
an FD where W, Z, Y. or any combination of these three L'i a determinant. \YJc c:m
use 'rZ - t X , and now we assign l-'\rZY U X to result. Since we have found that every
attribute of R is in 1,1,Z+, WZ is a superkcy.
To find W+, we assign W to result and enter the while for the first time. Using tbe
FD W ,-+ Z, we assign VI U Z to result Since we had a change to result, we enrer the
while again. This time we use WZ-+ Y and we a5Sign W.ZU Y co result. Now we look
for an FD where any combinat ion of WZV appears as the determinant. This time we
can w e yz -+ X, and we assign- wzy U X to result. Since we have found that every
atttihutc of R is in W+, W is a superkey for this relation. Because it has no proper
subset that is also a superkey, W is a candidate key n.s well. Note that we now know
that WZ is not a candidate key.
It is easy to verify duit yz is not a· superlcey. We start with resuit := YZ'. Using
yz -+ X , result becomes VZX. · Now we look for an FD where some· combln.>.tion of
Y2X is the determinant. Since there is none, we cannot add any new attributes to
result. This means that :a+
is only 'YZX, so W is not functionally dependent on YZ,
which means that Y2' is not a superkey: . _; .
Given a sec of functional dependencies, we wouli;l like to be able to dctcrmi~c whether
any of them is redundant, meaning that it can l:ie derived from the others.: To do ' so,
we can use the following algorithm:

l • . Choose a candidate FD, say X-+ Y, and remove i~ from the set of ~Ds.
2. J:'HW.t :• X; , ·.•.::,i;-J,.
while (resul.t c:hange:s and Y i5 not conta.1.ned in reaul.t) do
for each FD, A·~ B, remaining in the reduced ~et of FDs,
226 Normalization -7

HI ·-Inference Rules ·.
erence axiom s or A ~ ot g:
of inforcnce for function al depe nd encies,, ca~lt!d infthe FlJs logicallylmj;Ifcd y : ·.'·
Rules d all
er, can be used .ro fin
~axioms;-afcc~·che·i; d~esvelop
are soun d, -m ~ n ln g _ ~ ~ ~ at !_ .~ l) S ~ ti
en ce :
cy tli:a'i;
·set of FDs. These rul de ncy an d th at any functional deEf!nden
en
of the definition? functi secon=o;-~i~g· chem-is-·crue.-They""ie -also
on:i{ de.p 'completi;~
c;n"7be-dfrived· froma giv
en inf erence abour dependencie
s, so that~;
e ev ery .valid
meaning they ~canbe-usedbe''toderived from a given set of FDs, the given set of FDs does· · ;~
deriv
if a particular FD cannot FD. ·
not imply that particular ing axioms·~
s of a relation R: Th e follow ·1
Let .A, 8, C, and D be
A and
subsets
C.}
of attribute
.,
. hold: (Note: AC means ·l
1
,,,,. Fl. Reflexivity -+ A always holds. Fu nc
tio na l]
"-r'..
9

-also im pli es tha t A


-. 8. Th is :
If B is a subs_:t of A, then A called •tri'.;i:il functionai de pendencies.
e are
dependencies of this typ _,
;
/.
.._...,,. F2. Augmentatfon . J:
.
.. j;\.,
tHcn AC -+ BC ....
I( A - t B, •I
,.~
F3. Transitivity -
(•

ff A - B an d 8- ,. C,
Th e following rul es

Union ·
the n A _. c.

can be d~. rivc:d fr om the


pre v'lOUS .
th
ree:
I·j
\~ / F4. Additivity or
n A -+ BC.
If A -t- B a~d A -+ C, the
::.~_f,
position
/ F5.\ Projectivity or DecA-om :R
-~1
~-...,. ,..- 1£ A- + B.C then A-
+ Ba nd + C. .
. . f·ffl

.f .... . F6 . .Pseudotransitivity :.1.
.. p. .
:
i
./_/
J if A -+ 8 and CB -+ D, then AC -+
a fonna[ theory of functi
onal d ·. ~il
1cs, bu~11
---- ve lop nc
I
n be use d to de ep en de
These rules ca plications.
)

... -
we will concentrate ins
tead on the ir pra ctica l ap
R th . f ;'I~$

I
nd en cie s. for a rel ation all fun t'
is a set of foncri onal ,depe ·• e set O
c ioµa'.~.
.., (I f F ..
. . th b den·ved c.,rom F, F+, --is called the closure of F.) A~t ro ng '!,
.. .e if we were to a ;!,
dcpend~ncies , at can
axioms are su tnc icn t co
find
comp
all
ute all of F+: thar is,
the fun ~d on al de pendencies ·in F+. H!~ :
er, . e
rules
-~
I
repeatedly, we would lex an d cak e a lot of time.
I
1 would obviously be very co
mp eren e;·~
,;
nd enc:ics F of a relati
on R, we are often inc
t

lG iv cn :1 se t of fun cti on al di: pc


pe ndent on a certa in att ribute 0;1

~-,
'v
are fun ction ally de
in R th at
finding- all the amibures . ~- .t
~~:____.:..-- --~~ - '.t
27:8 . Normalization 7
1£ A i s a subs et of result,
then result :• ruult ua ,· ·\.
-,.._~
·1
t ond hen the FD X -+ Y i::1 redundant 1_ ·

J. H Y i:i il :,ub:lot of ruu l t, t :\

'\
y from the se, since it ~ be derived &om the ~
We could then remove the FD ~ -,h d mo;ing any that can be derived from !
B . every FD m t e set an re ~
ather FDs. Y rescmg f FD5 u·valent
1 co the original 5ct ·· ·l
the ochers, we can find a nonredundant set O eq f FD 11
r II · sec o
fo r c~ample, ?iuppose that we have the 10 owmg
s·· · . ··1
(1) W-+Z

(2) w- Y \
\
(3) Yl-+ X
\ ·,.
(4) wz- Y \
\
We be~in by testing (1) , W \Y/c assign W ro result. Now we search for an FI?
- •z.
[other than (l)J in which W is the detenninanc.. We find one in (Z), W ~ Y. ~o':J':e
assign WU Y co resuit. Searching for an FD having a determinant rhat 15 contame d.
WY , we find none. Therefore, we are unable to show _that ·Z is contained in result, ~ -- ;
we conclude that (1) is not redundant. ·
Next we test (2), W _. Y. We assign W to result. Searching fur an FD or.her than
(2) whose determinant is W~ we find one ln {1), s(i we ,;:an a:;sign t'VZ to result. Now
we seek an FD whose decermioa'n t is contllined in WZ. >Ile find {4) , WZ '4, Y , and
now we can assign w.zy to result. Since Y Is now comi.tn(!d in T~ult, we can exit the'
while and conducle that (2) is redundant. We now eliminate (2) from the set o f FDs;.'
Testing (3) , we assign 'IZ to resul t. We look for'an FD orher than {3) or (2) whose;
dercrininant is contained in VZ. Finding none, we conclude that {3) is not redundant. ,
Testing (4 ), we assign WZ ·to result. In (1), we see that the determinant, .W, is .
contained in result, so we could add the right side of (1), Z, to result, but it is already ·
there. There is no other FD whose determinant is contained in \>\-Z, except for (2),
which we have eliminated. Therefore, we conclude that (4) is not redundant in th~~
reduced set of FDs since we are unable to get Y in result. . •.-~
Somecimes we would like to be able to substitute one set ofFDs for another. If F ~
G are- cwo sets of fr>:,
then F is a c~ver or G if every FD in G·is also in F+, which
means chat every FD in G can be derived from the FDs in F. In the special case h ·· ·
Fis a cover for G and G is also a cover for F (i.e., F+ .. G+), then F and G arw • .d
to be equivalent.: A cover, F, for .G, is said [? be nonredundant if F is a cover ; 0 ;~h ·
but no proper subset of F is a.fover for G. . t:
G mny have several nonredundanc covers, so we would like to be able to ·find ·
. a st.andard , or canonical fonn .one1.1-Uat
. Ill
f FDs .in .1t and l5
.~1.f.
L -
hns che fewest num1Jt:r o 'ch ,,
each FD has a single attn'b uce on th e ng ·· ht s1'de. . ' m Wn1-~_14. ,
A ser of FDs, F, is said to be minimal if ._1ih1
~;Jf .
( l ) F has no redundant FDs ~~,
-•~:
(2) The richc side of every FD in F has a slngle attribute :(i
{3) No attribute on th e left sid•t of any FD in F is redundant. ·:~
~1{'.

II_
.
.
.

I I
I ,
7.5 First Normnl Fci~ . 2°29
I

• ~is ~eans that if x_- Y is an FD in


F, there is no proper subset S of~ su~h
th:t
and the ~esulting set' is equivalent ro F. ]f
F
. -: . can be us~ lil pla~~ of X -+ Y G. Intu itively, Fis a
.a minimal cover for
1
s.~mm1al and_equ1valcnt to G, then F·ls num ber of FDs in
than or equal to the
minimal c?vcr tf the number of FDs in it is less
set of FDs m~y have several mini mal cove~.
any canonical set equivalent to it. A

t
(\Y/e w;ll use a counrerexa~ple co ~escribe
first normal fonn. If we ·assume that :i s'.rudcn
iple mRjo rs in the
r, and we try to store mult
is permitted to have more than one majo
STU DEN T table might appear as in Figure 7.J(a).
same field of the student record, our
normal form, which is: )
This example viola.res· the definition of first
,)

Definition· of First Normal Form (lNF)

' .
.
. ,v .
.
.
or each "cell" of the table, contains only
This means that each attribute in each row,

-[ one va.ue. o repea ting fiel~%il_;~u·


first norm al form 1s to say'rnat the dom
ps~~aii~~;d2n af~emativew are atomic,
that is, they consist of single units char_ cann
Figure 7.3(a), we see this rule violated
airu of tfie .attribtites of"'arelation
ay~
ot be broken down further~ln ot1r tnhic in·
in the records of srudents S1006 and S101
d~c.: i-

0, who
ifiin i'

This is the first such exam ple we have seen ,


now have two values listed for MAJOR. fact,
now were in first normal form . In
because all th~ relations we considered until ugh thi!re is
ions in first nonnal fonn, altho
much of relational theory is based on relat first norm al
relations.Ur. is important to have
current research on non-first-normal-form
have defined them , will work correctly.
For
we
, form so. chat the r~at iona l operator~, a~ bra operation SELECT STUDENT WHERE
: example, if we perform the relational alge
should the record of student S1006 be
MAJOR ='Mam' on the table in Figure 7.3(a), some other table u.sing MAJOR: us the
,virh
included,.If we·W~re to do a narurat join
joining colurMt would this record be paire
d with only those hnving both CSC and Math
.
or Math? What would hnppcn on ~e join
as MAJOR, or with those having either CSC d th~e amb i~~ti cs, we
Math CSC ?~ avoi
if another record had a double major listed as
be written in first normal form .• If-a rcla.t1on Js no,E.!lreoqy
will insist that every relation1
es!=}:i._c{th~ Jl!~1apJs...'@.l.tJst ~Eecnrs)n
Jn.lNF, we can rewrite jt1..'. fla~f;Qi{lg'.:..it.:so:.tl;tat. STUDENT tab!~ as in Figure.J.3{b) .
ite the
.a different•.rQW.: Therefore, we would rewr
ID, since any student with mon: than ;~nc
...:.. Wei°lsonoremat the key is no long er STU
STI JID ,~JO R (or SOCSECNO,MAJO~
)
major appears at least cwlce. _Now we need .. . - ,· . ~ _. } .
-co identify a record uniquely) .
.
... ! .,.-::.
~·. \.

' ..\ ~:::!~"'-


-~i. @i!
vl .,.,__ ___:___ __ __ __.... ..,,.ara
' t•
~ - (I .

. . ,. .,(•, •• \ ..~ : .I
I
• <. :' ; .
2.30 Nonnalization 7..., ,
cR£ OI'l 'S ISTA TUS I SOCSEC
STUNAME 1 •
1u11JOR NO 1
I , ..,,.
--- --- - 1-- --- -1- --- --- -1
1STU ID , --- t-- --- --1 · ., 9 soc I
1-- --- ! --- --- --- H' tor y 190 I sen J 100 4 ...
~ t1. Tom I .1.s
S
1s10011 mM ''' ___ 1 -------1------- 1-- --- -1- --- --- --1
,-----i--------- h 195 1sen 10101245671
1s1003tJones,MarY -'~~=---- 1--
1-- ---1 .~- "--- ---- -- I
1s1 006 !Le e,P ame la
,~s -----1tFr---esh---1--------- 1
tCS C - I
108 8S2 087 61
1. · I I
I I Math '-- --- --1 --- --- 1- --- --- - I
1·--- --1 --- --- --- --- 1-- --- -- l
c.3 jJu n 10993209851
1s10101surns,Edwardt.A.rt . 1
I I · l I
1English l _______ ______ ______ _ I
___
1-- --- 1-- --- --- --- -i- --- --l r 1 1 1
IS10601Jones,Mary ICSC fre s h f064 6247381
l ~S I
Figure 7.J(a) STU DEN T Table
major)
(;:~:t~t---
s may---have---mor---e --- --------
than onr

-· / I STUID I STUNAME IMAJOR I CREDITS I STA


TUS l SOCSECNO I
1-! :--- 1-- ---- ---- --1 ---- ---1 -
! Sl0 0l I Sm ith, Tom l His tory I 90
--- ---1 - --·- -·- i
l Sen
-------- 1
1-- --- 1-- --- --- --- -1- --- --- 1 --- i:i 004 295 00 I
IS10031Jones,Mary !Math 195
----1-
jSe n
v --1--------- 1
1-- --- 1-- --- --- --- -J- --- --- 1-- 1D1 012 45 671
1S1006!Lee,Pamela ICSC --- --1 - --- -- 1 --- --- -,
115 fFr esh j0 B85 2 0B7 6 1
1-- --- 1-- --- --- --- 1-- ---
1S1006fLee,Pamela IHa~h . --1 --.
115
---1------1--------1 ii
1-- --- 1-- --- --- -~- -1- --- --- 1-- IFre ~h 108 852 087 6i
lSlO lO( Bur ns,E dwa rd lAr t
--- --1 --- --- ,-- --- -1
163 (Ju n IOS93209851
·i 1-- --- 1-- --- --- --- -1- --- --- 1--
'
' IS1010!Burns, Edw ard 1En glis h l 63 --- -- r --- --- 1-- --- --- - ,
JJu n (09 932 098 51
1-- --- 1-- --- --- --- - 1--- --- - 1--
--- --1 --- --- 1-- --- --- -1
IS10601Jones,Mary ICSC 125 !Fr esh 106 462 473 8( ..
:1'
Figure 7.J(b) STU DEN T T:ahlc Rc~~:n-~-
lNF --- --- --
Figure 7..3

!D_Fu~l Functional Dependency


/'

Consider the rclarlon


.-:~ . . .

. .. lcLASSCCOURSEI . sror o, Srt1N1.MI!:, F.Ac:ID,


.
sc:imo ltOOM .,
• , r Cl0. Jl£) J
In this example we will assume that CO
and chat there is only one faculty mem URSE# includes th d
ber for each class (' e epanment and · ,. ·.
SCHED is a string that gives meeting section,
days and time, ·an: /R~ ::.a ~ teac
and room where the class always meets. hing ). ~ 1
. An in.stance of th. . glves the bui ld~
7.4(a ). is re 1at.ion appear,s in FI
,... gurc
.• :r"
·.....
~

..... ~

----... _}i
I

I 7.6 Full Fun~tlorml Dependency· 131


fCOORSEIIST~IDfSTUNAME IFAClO]SCRED JROOMIGAADEI
1-------J--7--l------------ 1-----1-------1----1-----I
fART103AIS100llSmith,Tom . IF101 IMWF9 !H2211A 1
r-------1-----1------------ 1-----1-------1----1-----1
IART103AI 51010 !Burns,Edwa: dlE'l0l IMWF9 I H221 I I
1-------1-----1----------~--1-----1-------1----1----- J••
IARTl03AI S10061 L ~e ,.Pamela IFlOl IMWF9 I H221 IB I
1-------1-·---1--------- -- 1-----1-------1---- 1-----1
ICSC201A(Sl003,1Jones,Mary IF105 ITUTHFl0IMllOIA I
1-------1-----1----------·~- 1----1-------1----1-----1
ICSC201AIS1006(Lee,Pamela 1Fl05 tTUTHFlOIMllOJC I
1-------1-----1 ---------~ -1-----1 .------1----1-----1
IHST20SAIS100l !Srnith,Tom . IF202_ rMWFll IH221 1 1
-------------------------~---------------------------
Figure 7,4{a) CLASS Table

ICOURSEflSTUIDIGAAD~I ISTUIOISTUNAME I
1------1-----1-----1 1-----1-------------1
ISlOOlfSmith,Tom IV
IART103AIS10011A 1-·
1-------1-----1-----1 1-----1-------------1
JSlOlD(Burns,Edward I
' !ART103A}S1010 I · I
1-------1 - ----1----- 1 1-----1-------------1
I 51006 l Lee , Pamela I .,,,-
IART10 3A l Sl 006 1B I :/ ·
1------ -1---- - 1-----j 1-----1-------------1
1S10031Jones,Mary
(CSC20l AI S l.0 03 1J.. i ~N'
1---- - - 1------1-- --1 ---------------------
.STL)', Table
JCSC2 01A I S1006 IC t~'
l------- 1--- - - 1- - --l
IHST205A1Sl 0011 I tCOURSEf!FACIOISCHED )ROOM I
--------------------- 1-------1---~-1-------1-----1
i~RT103AIF101 !MWF9 IH221 Iv ✓
CI.i\SS2 Table 1-------1-----1-------1-----1
- • ! CSC201A]Fl05 !TUTHFl0IMll0 Iv'
r-------1- ·---1-------1 ·----1
'. HST2D5AIF202 . lMWFll !H221 I
~COURSE
--------------------------
Table
Flgure 7.4(b) CLASS2, STU, and CO~SE Tabler. ..
Agure 7.4

We he.ve the· foifowing functional dependency


~ ': .
. .,-~
cotmSEf,STUIO-+ STt!N1J«, !'AC! D, scam, ROOM, Gn.DE
' I • l

Since there is.no other candidate key, COURSE#,STIJlD is the (composicc) key for
the· relation. Ignoring ttlvlal functional dependencies, we also have the functio~ol
dependencies · ·

COOltS!,lf-+ FACID,SCH!!D,JtOOK ,
STUID - t 5Tt7l0\MZ
.~. on the eoa,. '
·1 .
7· . " that arc functionally dependent
232 :,. N~J~;,;Cion • . set of that com.
we fmd atm buce cc1.on.a II y deN 'ndent on 11a sub
d d
/ · [ 1 e cases . L I fun r-- ·
y epen enc on the
n both oCOnes • ~ so oc fully fun ctio na
. . URSE;;1,STlJlD.h uut:
~ mac~on that suc attriburcs are n
bin:u:1on. We.. say
.
com bin ati on .') ·
. . )
•✓,Definition ~f Full Functio1~1-T.l De· pend• en ce
na11 d pendent on an atmbute or set
:J
.

DEFlNITION: (1n
1
a.relation A,'attribuce 8 of ~ na
'of .mributes A of R if 8 is.. functto
i5 flf llJ fu n:~ t
Y epen
o: ·1
A ~uc no t functionally dependent ~
1
.J
-
;,,_\~•"\.
on any proper subset o( A,)
.. COURSE#,STIJ!D•~
fi .. . ally dependent on atio
. •
AME 1
' unctto~t: of char com
bin n, STUID. SJ.m· j
In our example, although STUN ent on the proper subset ;j
ic is also functionally depend enr on a proper .su. II y denr Pnd bin!)tjon ~
ED d RO OM are (uncttona ly de pe nd en t~.th. e co m .~ ~
SCH , an fu!{ fun' . nal . ·-1
ilarly, FACIO,
COURSE#. We not e
,_
that GR AD E is Y cno -
. J
CQ UR S~ UI D: M
~~,

I.Second Normal Form ~·{. ~


1 :~,
\• •
.:;,
Definition ·of Second Normal For_m
-(2f.lF) ·1f
:1:
t normal .foo/1 at:~j
i
. DEFINITION: ~ rda
_:
ti~J
~
E..i
n~ke_y
'!!:S
~t
~ll9
r~
.E.<
_:
?!J
1,: :
fl.aJJ2
full
,~ (2_~.f.) _if_and oElYif it is in firs
y ~c~~~ on rhe
key.). ~ · 1
_:~ftti
,
~ F and the key 00nsist5 of a ff. ~• ~~ _; <,
th,: relatiru,;'.,
{flear ly, .if a ~ la ti ou t~ is when the key,
.~ nly tim e we_have to be con ceI E~ ab
au ro rn an ca ~~ -:.
see tha t the CLASS relation
is no t in sec o -
Fro m the del lofo on, we
y functionally dependent on the
is compos ite. ''!"
not full
ilormanorm. For exa mp te, ST UN AM E is
re are other nonfuU functional dep.
endencie5 her e,· on
CO UR S~ ,ST lJI D. Alt hou gh the ..
is sufficient ro show that the
relation is nor ZNF.) lie s ·
ma
t is not 2N F exh ibit s the u~ e(U"!:5.!_~ion, and del eti on ano
( A relation tha
pose that we wi.sh to change the-s~
nedule of AR 03 b

we referred [0 in Section 7.1. Su~ CL.Ass tabl'


we m,g ht update the fuse two records of the
to MW FI2 . It is pos sfbl e
nt 1cate in the database. It wo
uld the
inc ons iste
but nor· the thir d,. res ulti ng in an
t class. ,This is an update ano
mal ~ Ari
the true sch edu le fur d1a
be impossible w tefl course for wh i~ ,
on ano ma ly occ urs wh en we try to add information about a
l inserti
iste red . Bec aus e the key is CO UR SE#$TUID, we are not Pc nn l~ 1
student has yet reg ormatlo . ... "
, so we arc unable to rcc:otd the course inf
./ to insert a nuf l val ue for ST IJID
CO UR SE #, _F' ;CI D. S~ HE D, and .ROOM values av:U:.~i ,
though we may hav e the ma!y.j .
{
are no t .ible. ro rep rcsth:s
en: •~o nnat1?n, we have an ins ert ion ano t , !.\. .
Because we t1on about a student who has no

Il
re mfo rma
en we delete the teGpttl or'rh .
occ urs ,£ we try to ms 1.
similar problem ly occ urs wh
A del etio n ano ma
registered for any course. 7;•: .

l.
I ,i • 7.7 Second Normnl Form. 233

only student taking a ~anicula~ cou F I . ·


we lose all ;~ronn . bo : rse. or examp e, ,f student S1001 drops l-lSTIOS t,.
u,I! at1on a Ut that C:Out~ { ' d • bl k ' t
but we cannot do s . , e, t is cs,ra e to eep the course informncion
only cours·e
A lNF
th -t h o_
e or 5 e is
l a_
WltO~t
c:;.orrespondlrig SnJI~: _Similarly, if a student drop.; th~
mg, we lose all information about chat student) . 0

, n:Wation that is not 2NF can be transformed ·in~o an equivalent sr:c of 2NF
re Iat1oru. e perform 0 • t' th ·· 1 I · •
possible to - • pr !~c •~ns ~n e .on~~~~ ,:C :i~•~t:. •~~uc}:l_ o. w_ay t~:it iLis_
tflrs•-· gee back tfiU2J:ig~l}__~l by t.11.fu.!:ig tne J~!\_Ql.the_projections, Projections of
Esse:r
fa
are called lossles~ proj ections ~nd :i.~c dlsc:ussed In more derall In S::t~ ?_:14.
al~y, t~ make a relation 2NF, you 1denu(y each nonfull functional dcpcndcrv.:y nnd
~ pro_1cct1ons by removing the attributes that depend on each of the dctcnninants
so identified. These determin ants are placed in separate Tclations along with thei r
dependent attributes. The. original relation sci!! contains the composite key and .1nv
attributes that are fully functi onally dependent on it. Even If there are no attribut~
fully functionally dependent on the key of the original relation, it is lmpominr to keep
the relation (wlth only the key attributes) in order to be able to reconstruct the original
relation by a join. This 11conn~cting relation" .shows how the projections are related. ·
Applying this method to our example

CLAS S (COURSE: f. STOID , STUNAME, FACIO , SCHED, ROOM, GRADE)

__we first identify all the functio nal dependencies char we are concerned abour. They arc

... ~ - ~• .- - - . ... _ _ ·- -- - ► & • • &·------..


• COORSE I -+ F ACID, SCHZD, ROCH \ "
I STOIO -+ STUNAl-tt
l COORSE l , STOID ..... GRAD? ( ;i nd, of course, FACIO, SCJ!ED,ROOM,STtml\ME)
'---- - -~- - ·· • - . ... . . ·- · ··---·-·· ·- ·-·-· ~-·- ·-· ··-·. :···
Using projection, we break up the CLASS relation into the following set of relations:

\
~=··---\
, ~::io::~
COORS£ (cocm.sef, FAcrD, s c m:o, ROOM)
I STO (STO!O, STUHAHE} "'
'----··· ·- · . --·· ----
The resulting relations arc sh own in Figure 7.4(6). Note that we could r~construct
the original relation by talcinr the natural join of these three relations. Even if there · ·
were no GR.b.J)E attribute, we would need . the relation CLASS2CCOURS'E#.STU1D) -~ ·
in order ro 'mow which students ar~ enrolled ln which cours~. Without It, we could .
not join COURSE and STI.J. Using these new relations, w~ have eliminated the update, ·.
insertion, and deletion anomalies di.scussed earlier. We can change the coum schedule
for'ART103A by updating the SCHED column ln a single record _in COURS~. We
can add new cowse infcmnation to COURSE without having any student reg15rered
in the course and we can insert new student information by adding a record to fi'TU,
without hav~g to insert course information for that student Slmila~ly, we c:mdrop a_
'registratlon record from CL.ASS2 ·and still retain the informntlon a~ut the c!'.Tsc:t
C'QURSE and about the srodent in STU. · .:t;.
~i.·.
,, ~
f'

. •:t:
·:•,t·
'll.
'I
..\1. . .2.34 No~lir.atiQP 7 d
.m. , ml Transitive nepen ency
JiI . la ,ons are L. •r than those in ·nth
m flnonnal
':'~ Alch ough ..,.cond..normal;form re nd- I . Ot;tt... II . fonn,
. rl...:..".
..~,
I ,· "" . . d e ec1on anomalies. Consider e o owmg rtlatiOll}~
•[~ may still hove update, insertion, an . . . };
,'
i/;1 . • MAJOR CP.EDI'l'S, sTAl'OS} )1
1~ STOt>ENT (STOID, SftJlW!l'! • ' · ·.:~
;;j/ · _ . . H . the only candidate key is STIJID;:
)i Figure 7.5 (a) shows an inst~ce of th is relat1~lcr ::;ibutc of the relation is functioN!-llY1
',fJ
j(
so we will use that as the pnmary b\ E~e
dependent on the key, so we have t e O1owin
7.
g functional dependency. among ochers:.i
~~
,F .
,...
''
El •l~~i

STUID - t CREDITS . . ~~
j
,ff.: ,
)~{' However, since che number of cred1!.S detemuncs ..:iC"T"A'TIJS
. as discussed in Section 7.2,:~
. .
-~1
;t'• Ul. 1
?J
.ill!
.'·;~-
wec::I:v~ s,Ams
.
· . ·:j
d::~
; if/, Thus STIJID functionally detennin cs STATUS in two wny.s-direcdy, and trnn.sitiv. -1j
_~
1
)J through STATU.S:_. _ -· --- ·· ·- . . ___ __ _ ..
~~,;. .(_t-1·
f/
i ~t F,,;;;D : .""".~,...,. ~ (~.:~· :-.~~~~>
.~ ( ~D .:::!.~".'."!l \ :?-'ii
:Jj R;c;i, ~ t transitivity is the thi«I of Armstrong ', axioms. Thus a transitive depend ~
. /r1j is orie that "carries ovei:" another attribute. EYu¼.tpJy,_L~J.9v~_~eQ!;nd c q ~ ~
; .~-4 when one nonkey attributt; dete~e.s another, no~~- ~':!!!~.!!te. For thud normal fo~
{ijf
:.tf i~
p
weconcences.'
rareoo·reracions
dependenci
w~th only one candidate key, and we eliminate transitive 1
· 1
. !,~J).
4"~~-:
1Lf
{;a: ·
!:~~- ·
l.~'. -£
j{(·
; SJ. Third-Normal Form
~11: \
i1:[ Transitive deJ>endencie.s cause insertion, deletion, and update &no~ics Fo
..
ij J
th t
l!l
:.t
1-L
in the STIJDENT cable in Figure 7.5, we cannot insert the infortn.ation,
with 30 creditS has ~oph Status until we hav: such:a sru~ent, bccaUSc
insetting a record without a S1UID, which IS not perm1tftd. If we delete th
that~:~. .
r

~
' .; the only student with a certain number of credits, we lo.;e the infionnac· eabo. "':
: I If ha
~ we ve several records with thc·same
__ .J, 10n Ut
status associated with those cn:u1ts. · .i
_value and we change the status ~iated wl?1
that value (e.g., making 24 credir.s· ·
have scacus of Soph), we may acetdentally fail to update all or the records. leavh{. ·
database ~an inconsistent state. Because of ~ese ~h!c:ms, it is desirable to ~
- - · -···· ~
5
7.9 Thlrd Normal Form 23.
. ICR£DITSISTATUSI
IMAJOR
ISTUI01STUNAME l I
1-----llS -------11H
1-----To -------yl91- - tse n t
istor 0
ISlOO mith, m ---- --1I
--- ---i!Se
1-----1-------Ha--ry---1!M---ath----1195 n
. IS 10 03 1J on es, --h-- 1I
--es
1- --1-
--06 -- -- --me--la---1ICS ---- -~-1ll5-------1'! Fr
C
IS10 1Lee,Pa
I .:
---10-,1B
1-10 ----
. .--s,E
--urn --ard1-1Art----1-163------1-!Ju--n---rI
--
1;·1,t
' JS dw
~---- -1---ne--- ------ 1---- ---1-I 25------1-!Fr---es--1
h I
ICSC
IS1060('Jo s,Mar:}t
~-EN
----7,5--(a)-~Sr--uD
--ure ---- -- --
le
-- ------------------
Fig T Tab

IMAJOR I CREOlTS I ICRE:OITS/STATUSI


ISTU ID 1STU'NAME 1-------1------1
1---- -1--- ---m---1-1H---
---To ---1-l90------1I 115 !F res h I
ist ory
ISlOOllSmith, 1-~ -- -- -1 -- -- -- 1
1- --- ---,M---ary---1-!Ma---th---1-195------1I
---es
-1Jon 125 IFres l1 I i
IS10031 1- -- -- -- 1- -- -- - 1 I

1----1-----Pa--me--l -- -1----- --1115 -------1I 163 !Ju n I


a ICSC -----1I
ISlD06JLee,
-- -- ---t----,--
-1Ar . .----1I 1-------1-
1-----1 ---- 163 190 ·1sen
ISlOlO( Burns , Edwa rdl
- - - - ·1-------1 r-------1---n---1.!
1- ---- 1-- -- -- -- - - - -1 --- 125 l I 95 · !Se
JCS C
!Sl06 01 Jones,Mary
- ----~-------------- ~-----------
ST02 Ta ble
STATS Ta ble
TS Tables
Figure 7,S{h} STUZ and STA
Figure 7.5

ns_that satisfy the following definition


.transitive dependencies an4
.create a set of relatio · · ,.. , · -· ·
ate key):
only one candid :
{applied t.o relatio.....ns....with

rm (3NF)
De finition of Thir~ _Nonna.l ·Fo

ber\~e charac teristics of ihl


rd
rasing Kent (see ~e Bibliography), you can rcmcm the -ke y .th c whole
~araph st·depend ·on
t ~c h nonkey attribute mu
1

'
normal form by saying tha
and nothing .but the key.)
· . ·
fotn},~~_l_~~- ro..:,ec_!~ ·
j / n ch~~ _a s~o ~n orm al- f<?~,:elation.for,third_t,1f)tm.aj_key
ctfonally dependent on ano
ther non atttibute. If such a
nonlcev attrioute 'ts funstS, we rcritovcthe functionally dq,encfent attrlb~~-from ~
eperulency CXt
the~ .
rem n~~
ctio
.tncwrclatio~with itsd~tetm
l.nint "Q_le-dei:ennlriant Bin
entl~~cy is
relation. liclnfi'flioii"n. ' For'--o·Jr STU example'; sincti:he und"eslrnb'fe'ifep !;
-m np lr el at set of relations ': ··'·
CREDlfS -.. STATUS:-we fonn the
,,.,.
..i:1
236 · Normali2atiol}.] _!._{'
/ MAJOR, CJU".0:rTS)
sT02 (STOIP, sTIJNAME, • . ·.:_ ••.
0 ITS STATOS)•
, <cnt
sir11--rs ' ( f e may de"cide not to stott
. ?.5(b). ln actt w . · "
"(on
1 is shown in Figure tli c-rATlJS for those VlCWS that need
This decomposi [l d calculate e- ..> i, • .1 t
Us · h database at a , an 1- • • ~ i
STAT 1n t: e
ic. In that case, we simply drop . t~
th STATS reIBt1on1 · -A b Cod~ lt.is
·s the origtnai one dcvclol:-"""' y d fi i lri
This definition of third norma .orm. i didate key, bu·c was found co be c c t.
sufficient for relations chat have a sdinte c~n and ;here candidate keys are comd
cases where there arc multiple can i at~ de~•t'on of third normal form, nnmc 0 \?
r.lr
11
and overlapping. Therefore, an improv\ ed ake care of all cases:\ .'' •. .
developers, Boyce and Codd) was formuiatc to t . 'l ".! ., ··

·Ellll B~yce-Codd Normal Form


Definition of Boyce-Codd Normal Form (BCNF)
. ,n F) if
m Boyce-Codd normal' form (BCl).. ' and on'y
• if every detenni.nant'-).'i
ft.. • • 1
D8FINIT10N: '0 relation 1s . ',i
a candidate key.} •
I . . 'jl
(For a rela tion with only one c:an.didate key, thiccl r,onnal fom, and ~oyce---Codd no~
fonn are equiva!ent. In fac t, some auchor,; rdi:i: to this dcfmit:on as the standard one ~ot
third normal form. Note that unlike p~vious forms that started with relations alrµd
in the lower normal form, this definition does not state that the relation must fus,t._.
2NF and then satisfy an add itionnl condition.. Therefore, to ei.~eck for BCNF, we simp1Y,
identify all the detcrrninnnt!e and make sure that they are c,andid~_keys. However, :al
relations that are BCNF are also 3NF. ) .~
tetumlng co our earlier example~ to check directly for BCNF1 we see that f~r ~ur
STUDENT relation of Section 7.8, shown in Figure 7.5{a), the determinants arc STUID
and CREDITS. Sine!! CREDrrS is not•a candidate key, this relation is not
Perfonning the projections as we did m. Section 7.9, the resulting relations arc BCNF. Fbr
the relation CLASS_ in Section 7.7, shown in Figure 7.4(a), we found the detet:minam
COURSE#t which is not {by itself} a candidate key, and SfUID. also not a ~idace
key. Therefore, the CLASS relation is not BCNF. However, the relations resulting fro"
. the projections arc BCNF.) · . "'~ ,
Let us consider an example in which we have overlap_ping candidate keys: ·

,i FACiJLTY (FACNAME 1 DEPT, OE'FICE, JWfll:, DMEB!Rl?D) .· ~


• ·t ..... ·'
For this example, we will assume that although faculty names are not unique no ~ :
faculty members Vt'.J,:hin a single department have the same name. We also ~ !
each faculty memberlia's only one office. identified ln OFFICE.. A department m:aihave'
several faculcy offices, and faculty.members from the same department may share. offi ••
From these assumptions we see
I OFFICE -t DEPT
l_!~t! ~ - t
.
O!'FICX, IWa:, DJ\TEHl'EW> ·
7.10 Boyce-Codd Normal Form 7.37,

. JU\NJt;
t,,\O:(AME,.~ F!,_l~. -i- DEPT, DA'J.'ERIJU:D
'

Our overlapping candidate keys are FACNAME,DEPT apd FACNAME,OFFlCE. If we\


choose FACNAME.iDEPT as our prlmary key, we are Iert with o det~rmin:int, OFFICE,
1. that Is notacandidate key: ~Tiiis vTo1aic.s'aCNF. (Note thut the relation is JNF. le is
tf INF because each cell has a single value. It is ·2.NF because even though the key h.is
~
two :mribuces, both nrc: needed ro determine the nonkcrj attributes, OFFICE, RANK,
~ and DATEHIRED. It is JNF because there is· no transitive dependency. Even chough
r.
; OFFICE determines DEPT, the 3NF definition is not violated, since pey is. part of_ the
t key.) To reach BCNF, we can decomP,(?~e .the. FACULty__rel~tJ~~ ..~); P!Ej~c.t)QQ into
r --·

' •
•• FACl (DEPT, OFFICE)
FJ\C2 (FACNAME I OFFict:,, RANX , OATERIFEO}

I
C.. The key of the fim rdntion is OFFICE, since a deparnnent may have several offices, but i
each officeb~l~ gs to only one deprirtment. le ls clearly BCNF, since rhe Q!l.lY_ de term i-
nant is the_k;ey. The key of the second is FACNAME,OFFlCE. It is aiso BCNF, since
i.sthe·lcey~·Note;-h-owever; mai: our fmnlsclieme does not show the
its only determinan t
functional dependency FACNAME;DEPT ...... OFFICE, RANK,. DATE;rilRED. (Nore: .
. If we had chosen FACNAME,OFFICE as the primary key of thc-otigina l FACULTY
relation, we would have OFFICE - DEPT. Sine~ OFFICE is not a candidnte key, the
relation would not be BCNF.' ln fact, it would not be 2NF, since DEPT would not he
l fully functionally dependent on the key, FACNAME ,OFFICE.) )
A relatioi-1 may have overi.app;ng candidate keys and still rbe-B.:tC;,w;N~F-.F....or cxamplei let

I
l
us consider the relation ,

Here, we will assume th~t a student can have only one major and that borh of the
combinatio ns STIJNAME,STUADD and·STUN ~E,MAJO R a·re unique, so we hnvc
two overlapping candidate keys. If we choose STUNAME,S11JADD as the primacy
n
key, our on ly other dcrenninam, STUNAME ,MAJOR, is c:mdidnce key. Therefore,
the relation snJ is already BCNF, and there is no need to decompose it. .
Any relaciqn.•chat ls not BCNF can be decomposed into BCNF relations by. the
method illustrated. However, le may not alway5 be desirable to
traruform the relation
into BCNF. In particular, if there is functional dependency that ts not preserved when ·
l
;
l
we perfonn the dccomposltion (i.e., the determinant and 'the attrlbutcs it detrnnines
end up In different relations), it is dif6cuk to enforce the functional dependency In the
database and an importanr constraint is lost. In .that case, it is preferable to settle for
JNF, which always allows us to preserve dependencies. Our FACULTY rclat-ion provided
an example in which we lost a functional dependency by normali.ting to BCNF. lri. the
resulting relations, the attributes FACNAME and DEPT appeared in different relations,
and we had no way co express the fact that they determined all ocher ntttibutes. · ;:

•,

~ ·--~ - .....__! .../i~&,l'fflFtlii!!@tiij


~ I

238 No:malization 7 "!I

Im! ·Coniprehensive Example of Funct~onal -~


.~.t
Dependencies ;,~

.
,1:
-~
To summarize the various normal {orms defined by functional dependencies.let us con~i
side~ the 'followirig relation that store, infonnation about proj~crs in a large business:~

iTOrut-+ (PROJNJI.ME, PROJ'MGR., ZMP:CD, SOURS, J!!:MP?WiZ, • !ln'DC'E~r STAATDA'l"E:,


SJ\LAR.Y, EHPMGR, t.HPO:tP1', RATING)
:J~
:~~~~~:::~~~:~::~:~~:~~~~=:~~~~:~~~:~::=~~:~~:::=~=:· Ii
!Jupiter 1smith IElOl /25 fJone s 11aoooors9Dll5 140000 I ·
I ---- --""-1-------1 _;__'__ I--·--- l -------1 ------ r---------1------ I ~-,;11

IJupite~ ISmith IE105 110 !Adams 1100000J890115

:;~;:;;:-:;;;~~--:;~;~-: ;~---:;;;;::-;;;;;~;:;;~;;;---:430001
[55000 (

:I ~J

: ;;:;~~--: ~~~-- : ElOl : 15 ; Jon;-s ·: 201)00G: 90. 0301 : 40000 : :i~~-


l---~----I-------1-----1-----l-:------ i----~,-- J -·--------1------ J .
IMax:i.rna ILee 1El05 130 !Acianis l 2l\DOIJOHHJ03 01 155000 I _::
1---~----1-------1 ----- 1-----1 --•••--•••- !---~•--! =k••------- f-~---- , i~
~~~~~:~--~=ee I El.20 115 1 '.rafoaka ! 2000CHJ l 900301 145000 I. :~
---------------------·----------------------------- ·~
~MPMGR I EMPDEPT I AATING / ' . .~

------1-------1I ------1l
'~
Levine 110 9
-- -- t ----·-- 1------1
I
Jones-: 12 _____ : ______ :
7f."

r Levine I lO • 18
------ 1-------1------J
Levine:10_. ___ ; ______ :
I

l Jones 112
. ------1-------1------1
.: Jones I 15 ·
----------------------
I

I ·
(

Figura 7.6 WORK Table .·

Figure 7.6 s~ows an instan:e of this relation. Assume that: I


;,;·

1
• ~,h project hns a unique narne, hue names of employees and manngcrs are.. it
00~~ '
z. Ench project has one manager, whose name is stored in PROJMGR. ·

You might also like