Database Systems MQs
Database Systems MQs
NDEMULIROUNIVERSI
TYOFSCI
ENCEANDTECHNOLOGY
UNIVERSI
TYEXAMINATI
ON2014/
2015
MARKI
NGSCHEME
Ins
truc
tions
:
Sect
ionA:(Q1&Q2Compul
soryc
ont
aini
ng30Ma r
ks)
Sect
ionB:(Q2-
Q5Att
emptany3que
sti
onscont
aini
ng20ma
rkse
ach)
MARKI
NGSCHEME
KAKAMEGA2015
SECTI
ONA
Question One
a)Define the following terms: [4 Marks]
i.A candidate key i sa na ttribute( orsetofa t
tribute s)t hatuniquelyi denti
f i
esar ow.A
candi datekeymus tpossesst hef ollowingpr operti
es:
oUn iquei dentif
ica
tion-Fore veryr owt heva lueoftheke ymus tuniquelyi
de nti
fytha trow.
oNo nre dundancy-Noa tt
ribut ei nt heke yc a
nbedi sc arde dwi t
houtde st
royingt hepr opertyof
uniquei dent
ifi
cati
on
ii. A superkey i sa nys etofa tt
ribut e
st hatunique l
yi de nt
ifiesar ow.As uperkeydi ff
ersfrom a
candi datekeyi nthatitdoe snotr e
qui rethenonr edunda nc ypr ope r
ty.
b)Expla int hedif
f e
renc e
sbe twe ent henot i
onsofDa t
aba s
e( DB) ,Da tabaseMa na ge
me ntSys tem
(DBMS)a n dDatabaseSys tem( DBS) . [3Ma rks
]
Ada t
a ba seisanyor ganiz
e dc ollecti
onofda ta
,forapa rt
ic ularpur pos e.
Ada t
a ba semana geme ntsystemi ss of twa r
ethatall
owsus e rstos tore,modify,ore xt
ractinformation
fr
omada tabas
e
Ada t
a ba sesyste
mi sat ermt ha tistypi call
yus edtoe ncaps ulatethec onstr
uctsofada tamode l
,
dat
aba seMa nageme ntsystem( DBMS)a ndda t
abase
c
)Li statleas
tfo urr
espons
ibil
it
ie
sofada tabas
ema nage
me nts
yst
em.Fore
achre
sponsi
bil
it
y,expl
ai
n
theproble
mst hatwouldari
seifther
esponsibi
li
tywerenotdis
cha
rge
d,Ift
hes
erespons
ibi
li
ti
eswere
notme tbyagi venDBM,t hefol
lowi
ngpr oble
msc anOccur?[8Marks
]
i
. Interacti
onwi t hthefil
emanager
.
ii
. Integri
tyenf or cement
i
ii
. Securit
yenf orc ement
i
v. Backupandr ec overy
v. Concurrencyc ont r
ol.
d)Exp
lai
nthed if
ferencebetweenaweakandas t
rongent ityset.[4Mar
ks]
Answer:As tr
ongentitysethasap ri
marykey.Al
lt uplesint hesetared
isti
nguishabl
ebythatkey.Aweakent i
ty
sethasnop ri
marykeyunlessattri
butesofthestrongent i
tys etonwhi
chitdependsareinc
luded.Tup
lesi
na
weakentitysetarepartiti
onedaccord
ingtothei
rr elationshipwitht
upl
esinas trongent
ityset.Tupl
eswithi
n
eachpart
itionaredist
inguis
habl
ebyad i
scr
imi
nator ,whichisas etofatt
ribut
es.
Question Two
AMMUSTr egistr
ar’sofficemaintainsdataab outthefoll
owingent i
ties
:( a)courses,includi
ngnumb er,ti
tle,
credi
t s
,s yll
abus,andp r
er equi
s i
tes;(b)courseofferi
ngs,incl
udingcours enumber,y ear,semester
,s ect
ion
numb er,instructor(s
),timings,andc l
assroom;(c)students,i
ncludi
ngs tudent-i
d,name,andp rogram;and( d)
i
ns t
ruc tors,incl
udingidentifi
cationnumb er,name,department,andt i
tle.Further,t heenroll
mentofs tudentsi
n
coursesandgr adesawar dedtos tudentsineachcourset heyareenroll
edf ormustb eap propri
atel
ymod eled.
Constr
uctanE-Rdi
agramfort
heregi
str
ar’sof
fic
e.[
12Mark
s]
Documental
lass
umpti
onst
hatyoumakeaboutthemapp
ingcons
trai
nts
.[3Mar
ks]
Answer
:
Themainent
itys
etsares
tudent
,cour
se,c
our
se-of
fer
ing,andi
nst
ruc
tor
.Theent
it etc
ys our
se-of
fer
ingi
sa
weakenti
tysetdep entonc
end ours
e.
Theassumptionsmadeare:
a.aclassmeetsonlyatonepart
icularp
lac
eandt i
me.ThisE-Rd
iagramcannotmodelaclas
smeet i
ngatdi
ffer
ent
pl
acesatd i
fferentti
mes.
b.Thereisnoguaranteethatt
hed atab
asedoesnothavetwocl
assesmeetingatt
hes amep l
aceandti
me.
a
)Inyourownwor
dexpl
ai
nhowda
tai
nte
gri
tyi
sma
int
ai
nedwi
thi
ntheda
taba
sewhe
nconc
urr
entus
ersa
cce
ss
t
heda
tabas
e [5Ma rks]
- Whe naus e
ra t
temptstoupdatearow,alockisappl
iedtotherow
- Tr ansa
ction/lockinginfor
mati
onisplacedi
ntheblockhe a
der
- Whe nanotherus erat
temptst
oupda t
ethesamerow,theblockheade ri
scheckedforacommit
tedf
lag
- Theus e
rwi llha vetowa i
tintheroll
backsegmentheader,unt
ilthetransa
cti
onf r
om thef
ir
stus
eris
complet
e
- Whe nthef irstu se
rc omple
testhetransa
cti
on,thene xtuserwi lllocktherow andhavehis/
her
tr
ansact
ione f
fected
Question Three
Cons
idert
hei
nsur
anc
edat
abas
e,wher
ethep
rimar
ykey
sar
eund
erl
ined
.
Cons
truc
tthef
oll
owi
ngSQLquer
iesf
ort
hisr
elat
ionald
atab
ase.
pers
on( dri
ver-id,name,addr
es s)
car(l
icense,model,year)
acci
dent(report-numb er
,date,locati
on)
owns(driv
er -i
d,lic
ense)
part
ici
pated( dr
iver-id
,car,report-number
,damage-amount
)
c) Addanewac c
identtot hedatabas
e;ass
umeanyv
aluesf
orr
equi
redat
tri
but
es.[
4Mar
ks]
i
nserti
ntoacci
dent
val
ues(4007,’
2001-09-01’,’
Berkel
ey’
)
ins
ertintopart ic
ipated
sel to.
ec driver-i
d,c.l
ic
ense,4007,3000
f
r ompers onp,ownso,c arc
wherep .name=’ Jones’andp.dr
iver-i
d=o.
dri
ver
-idand
o.l
ic
ense=c .l
ic
ens eandc.model=’T
oyota’
Question Four
a
)Consi
dert
hef
oll
owi
ngt
abl
eins
tanc
echa
rt
Cre
atetheEMPLOYEEtablebas
edontheta
blei
nst
anc
echa
rts
howna
bove
.Choos
etheappr
opri
at
eda
ta
t
ypesandbes
uret
oaddi
ntegri
tyc
ons
tra
int
s [6Marks
]
CREATETABLEempl
oyee
(emp_id NUMBER(10)
CHECK( e
mp_idb e
twee
n0to999999)
,
Emp_na me VARCHAR( 30)NOTNULL,
Addr es
s VARCHAR( 50),
Join_dat
e DATEDEFAULTSYSTDATE,
CONSTRAI NT empl
oyeeemp_idpkPRIMARYKEY( e
mp_i
d))
;
b)Youar
eas
kedt
ode
signada
taba
ses
yst
emf
orahe
alt
hcl
ub.Theda
taba
sewoul
dcont
ai
nda
taa
bout
cus
tome r
s ,theirtraini
ng,c ontac
tnumb e
rs,et
c. Show t
hema i
nste
psyouwoul
dpe r
for
mfor
des
igninga ndimpl ementingthedata
bas
e.(Don’
tshowthea
ctua
lsc
hemas!
)
[
6Marks
]
Databases t
udy
Databasede s
ign
Impleme nti
nga ndloa di
ng
Test
inga nde valua
tion
Operations
Ma i
ntena n
cea ndevol ut
ion
c
)Inyourownwor
dexpl
ai
nhowda
tai
nte
gri
tyi
sma
int
ai
nedwi
thi
ntheda
taba
sewhe
nconc
urr
entus
ersa
cce
ss
t
heda
tabas
e [5Ma rks]
- Whe naus e
ra t
temptstoupdatearow,alockisappl
iedtotherow
- Tr ansa
ction/lockinginfor
mati
onisplacedi
ntheblockhe a
der
- Whe nanotherus erat
temptst
oupda t
ethesamerow,theblockheade ri
scheckedforacommit
tedf
lag
- Theus e
rwi llha vetowa i
tintheroll
backsegmentheader,unt
ilthetransa
cti
onf r
om thef
ir
stus
eris
complet
e
- Whe nthef irstu se
rc omple
testhetransa
cti
on,thene xtuserwi lllocktherow andhavehis/
her
tr
ansact
ione f
fected
Question Five
a)What is the meaning of the term ‘functional dependency’?
Ifiti
sinvali
dtohavetwoide nti
calvaluesofXwithdif
f e
rentva l
uesofYthenYi sfuncti
onal
ly
dependentonX
Why is it important to establish functional dependencies during
normalization?
Norma li
sat
ionisapr
ocessofs
e pa r
a t
ingFDs :2NFremovesfunc t
ionalde
pendenci
esfrompa r
tofa
compoundke ytoanon-keyat
tribute( pa
rti
aldepe
ndenci
es).3NFr emovesfuncti
onaldependenc
ies
bet
we ennonke yat
tr
ibut
es(t
rans it
ivedependenci
es)
.BCNFe nforces3NFforallca
ndidat
eke ys
(
remove
shi
dde
npa
rti
alde
pende
nci
es)
.
i. Give TWO reasons why the WORKRECORD table is not in third normal
form. []
Tobei n3NFthedatamustal
sobein1NFa nd2NFbuti
tisnoti
n1NFbec
auset
herearer
epeat
ing
groupsofda
taegthefi
rstr
owc ont
ainstwova
lue
sforGr
adeNo.Ther
ear
eals
otra
nsit
ivedepe
ndenci
es,
egbe t
weenGradeNo.andGradeTit
l e
.
empno
empna me,Pr
oje
ct_no,De
pt_No
pr
ojectno
Proje
ctname
Deptno
De ptLoc
Gradeno
Gr adeTit
le
Emp.No,Gra
denoStar
tdate
iv. Normalize the table as far as third normal form showing the
intermediate stages and the primary keys. Write down any
assumptions you make.
INF
T1(e
mpno,empna me,proj
ectno,pr
oje
ctna
me,de
ptno,de
ptl
oc)
T2(e
mpno,gradeno,gr
adetit
le,s
tar
tdat
e)
2NF
T1asis
T2.
1(empno,gr a
deno,st
artda
te)WORK
T2.
2(gradeno,gra
deti
tl
e)GRADE
3NF
T1.
1(empno,e mpna me,proj
ectno,de
ptno)EMP
T1.
2(proj
ectno,proj
ectname)PROJ ECT
T1.
3(deptno,deptname)DEPT
T2.
1asis
T2.
2asis
Mult
i-val
uedDependenc
y-apar
ti
cul
arva
lueofthede
ter
minanti
sas
soci
ate
dwit
hasetofde
pende
nt
va
lue
s
Arecordshoul
dnotcont
aint
woormorei
ndepe
ndentmult
i-
value
dfa
ctsa
bouta
nent
it
y.
SECTI
ONB
Que
sti
onTwo
Adat
abasecontai
nst hefoll
owingt abl
e s
:
game_record(gi
d,player
_i d,posi
tion,number
_of_goals
)
pla
yer(player_i
d,player_name ,te
a m_id)
te
am( t
eam_i d,te
a m_name )
game(gid,home _team,a way_team,ga me_da
te,goal
s_home
,goa
ls_a
way)
Thete a
mt abl
econtainsde t
ail
soff ootba l
lte
a ms ,t
hepla
yerta
blecont
ai
nsdeta
il
sofplayer
sinthet
eamsa nd
thegamet abl
econ t
ai
nss umma ryde ta
i lsofthega meswhicht
heteamspla
y.Thegame_recor
dtabl
ec ont
ains
rowswhi chdesc
ribethepe rf
orma nceofi ndividualpl
ayer
sineachgame.Ass
umethatt
a bl
escanbejoine
don
ident
ical
lynameda tt
ribut
e sandthatthea tt
ributes
home _t
eam,a way_te
a ma ndteam_i dc ontai
nva luesf
romthesamedoma i
n.
i
.Wr
it
einSQLque ri
eswhi c
hwi l
l:
a)Lis
tthete amsina s
cendi
ngorderoft
eamna
met
oge
the
rwi
thac
ountoft
henumbe
rofhome
gamespla yedbythattea
m;
Selectteam_name,count
(*)
fr
omt eam,game
whe r
et eam_id=home _t
eam
groupbyt eam_name
or
derbyt
eam_na
me
b)Li
stt
henameo fthehometeami nvol
vedinthemostr
ece
ntga
me.(
Ass
umet
hate
achg
amer
owi
n
t
hegametablehasadif
fer
entvalueforgame_da
te)
;
Sele
ctteam_name
Fromteam,ga me
Whe r
eteam_id=home _tea
m
Andga me_date=(s
electmax(game_dat
e)
Fromga me)
c
)Listt
henameo feacht
eamtoget
herwit
htheda
teoft
hemos
tre
centhomega
mepl
aye
dbyt
hat
t
eam;
Sele
ctteam_name
Fromteam,game
Whe r
eteam_id=home_tea
m
Andga me_dat
e=(sel
ectmax(ga
me_dat
e)
Fromga me
Whe r
eteam_id=home_tea
m)
d)Li
stt
hename sandpos itionsofSof apakaplayer
singame
swona
wayf
romhome
.
Sele
ctplaye
r_na me ,pos i
ti
on
Fromteam,ga me ,ga me_record,player
Whe r
eplayer.
playe r_id=ga me _re
c or
d.pla
yer_i
d
Andga me_record.Gi d=ga me.gid
Anda way_t
e a
m=t ea m_id
Andteam_na me=‘ Sof apaka’
Andgoa l
s_awa y>goa l
s_home
Que
stionThr ee
a)De scribet hea dva ntagesa nddi sadvant agesoftheus eofada tabas
ema na
gementsyst
ema soppose
dtoa
tra
ditiona lfilema intenanc esystem.( 5ma rks)
Di scus sionofi ssuess ucha s:
•
I nfle xibil
ity
•
Exc essivepr ogr amma i
ntenance
•
Re dunda nc y
•
I nc ompa tibleda ta
•
Cos t
•
Compl exity
•
Hi ghc ostoff a il
ure
b)De scribet heANSI /SPARCt hreeleve la r
chitec
turefordat
a basema na
ge mentsys
temssof
twa r
eand
expla int hea dv anta gesitpr ovi
de s.(9ma rks)
Interna ls chema :phys icalda t
aor ganisa t
ion,physica
lforma ts
,indexes,poi
nter
s,bl
ocksiz
e ,da
tast
ora
ge.
Conc e ptua ls chema :Logi calcontent,c onstrai
ntspecif
ica
tion
Ext e
r na ls chema:Loc a
lvi ewofda ta,subs etofconcept
uals chema
Loc
alVi
ew Empl
oye
e.Name Empl
oye
e.Name
Empl
oye
e.Addr
ess Empl
oye
e.Soc_Sec
_No
Empl
oye
e.Addres
s
Empl
oye
e.Annual
_Sal
Us
er
Us
er
Conc
ept
ualVi
ew
Empl
oye
e.Name :
Stri
ng
Empl
oye
e.Soc_Sec_No:I
ntege
r DBA
Empl
oye
e.Address:
Str
ing
Empl
oye
e.Annual_Sal
:Double
Conne
cti
ont
otheDBA
I
nte
rna
lVi
ew
Name :
Stri
ngLengt
h25Of f
set0
Soc_Sec_No:
Int
eger9Offs
et25
Address
:Stri
ngLength5Offs
et34
Sal
ary:9,2decOff
set39
Question Four
b)What is the meaning of the term ‘functional dependency’?
Ifiti
sinvali
dtohavetwoidentic
alval
uesofXwi thdi
ffe
rentval
uesofYt henYi sfunct
ional
ly
dependentonX
Why is it important to establish functional dependencies during
normalization?
Norma li
sat
ionisaproce
ssofseparat
ingFDs:2NFr emove
sfuncti
onaldependenci
e sf
rompartofacompound
keytoanon- keyat
tr
ibut
e(par
tialdepende
ncie
s).3NFremovesfunct
ionaldependenci
esbet
we ennonkey
at
tri
butes(t
ransi
ti
vedepende
ncies).BCNFe nf
orces3NFforallca
ndidat
eke ys(re
move shi
ddenpart
ial
dependenci
e s
).
vi. Give TWO reasons why the WORKRECORD table is not in third normal form.
[]
Tobei n3NFthedatamusta l
sobei
n1NFa nd2NFbutiti
snotin1NFbecaus
ether
ear
ere
peat
inggroupsof
da
tae gthef
ir
strowc ont
ainst
wovalue
sforGradeNo.The
reareal
sot
rans
it
ivedepe
nde
nci
es,e
gbetwe e
n
GradeNo.andGr a
deTi t
le.
empno
empna me,Pr
oje
ct_no,De
pt_No
pr
ojectno
Proj
ectname
Deptno
De ptLoc
Gradeno
CodeTi tl
e
Emp.No,Gra
denoStar
tdate
ix. Normalise the table as far as third normal form showing the
intermediate stages and the primary keys. Write down any assumptions
you make.
INF
T1(e
mpno,empna me,proj
ectno,pr
oje
ctna
me,de
ptno,de
ptl
oc)
T2(e
mpno,gradeno,gr
adetit
le,s
tar
tdat
e)
2NF
T1asis
T2.
1(empno,gradeno,st
a r
tda
te)WORK
T2.
2(grade
_no,gra
detit
le)GRADE
3NF
T1.
1(empno,e mpna me,proj
ectno,de
ptno)EMP
T1.
2(proj
ectno,proj
ectname)PROJ ECT
T1.
3(deptno,deptname)DEPT
T2.
1asis
T2.
2asis
Onl
yst
oreDe
pt,Pr
oje
ct&Gr
ade
sda
tat
hata
reus
edbye
mpl
oye
esa
ndwor
kre
cor
ds.
Mul
ti
-val
uedDependenc
y-apar
ti
cul
arva
lueofthede
ter
minanti
sas
soci
ate
dwit
hasetofde
pende
ntva
lue
s
Are
cordshoul
dnotcont
aint
woormorei
ndepe
ndentmult
i-
value
dfa
ctsa
bouta
nent
it
y.
Question Five