COS 124notes23
COS 124notes23
onkwoM.C.Cos124
COS104 I
ntr
oduct
iont
oDat
abaseSy
stem (
2uni
ts)
Cont
ent
:COS124 I
ntr
oduct
iont
oDat
abaseSy
stem 3uni
ts
Inf
ormationst orageandr etr
ieval,I
nformat i
onmanagementappl icati
ons,Informati
oncapt ure
and representation,anal ysis and indexing,sear ch,retri
eval
,informati
on pr i
vacy,integri
ty,
secur
ity,scal abili
ty,ef f
iciency,and ef fecti
veness. Intr
oducti
on t o databases sy stems:
component s of dat abase sy stems,DBMS f uncti
ons,database ar chit
ecture and dat a
i
ndependence,dat abasedesi gnandcr eati
onusi ngadat abasemanagementsy stem.Funct i
ons
ofadat abase;usesi nbusi nessandi ndustry.i
nt r
oductiontothef ol
lowing:datadict
ionaries,
normali
zation,dat aintegri
ty,dat amodel l
i
ng,andcr eati
onofsimplet abl
es,editi
ngadat abase,
queri
es,reports,andf ormsusi ngSQL.
I
ntr
oduct
ion
Dat
a has become v
eryi
mpor
tantasseti
ntoday
’s busi
ness and so mostmoder
n-day
or
gani
sat
ionshav
eaneedt
orecor
ddat
arel
evantt
othei
rev
ery
dayact
ivi
ti
es.Manyoft
hem now
chooset
oor
gani
seandst
oresomeoft
hisdat
ainanel
ect
roni
cdat
abase.
To mostpeopl
ethe comput
eri
s used basi
cal
l
yto pr
ocess dat
a.One oft
he cl
assi
cal
descr
ipt
ionsoft
hecomput sasapr
eri ogr
ammabl
edat
apr
ocessi
ngmachi
ne.Thecur
rent
edi
tonofI
i ntr
oduct
iont
oComput
erSci
encet
reat
sonl
ythepr
ocessi
ng(
incl
udi
ngpr
ogr
ammi
ng
andmachi
ne)butnott
hedat
a
Thebegi
nni
ngst
udentofcomput
ersci
ence,
inor
dert
ohav
eabal
ancedv
iewoft
hear
ea,
shoul
d
knowhowdat
a,whi
chr
epr
esent
smodel
sofr
eal
i
ty,
isusedt
odot
hat
.
Thi
schapt
erdef
inesdat
a,pr
esent
sabst
ract
ionsofdat
a,st
ruct
ureddat
a,unst
ruct
uredor
semi
-st
ruct
ureddat
a,bi
gdat
a(acur
renthott
opi
cincomput
ersci
ence)
,dat
abaseandXML
dat
ast
orage.Themat
eri
ali
spr
esent
edatal
evel
thati
saccessi
blet
othenov
ice.
Takef
ori
nst
anceauni
ver
sit
y.Mostuni
ver
sit
iesneedt
orecor
ddat
atohel
pint
heact
ivi
ti
esof
t
eachi
ngandl
ear
ning.Mostuni
ver
sit
iesneedt
orecor
d,amongot
hert
hings:
o whatst
udent
sandl
ect
urer
stheyhav
e
o whatcour
sesandmodul
est
heyar
erunni
ng
o whi
chl
ect
urer
sar
eteachi
ngwhi
chmodul
es
o whi
chst
udent
sar
etaki
ngwhi
chmodul
es
o whi
chl
ect
ureri
sassessi
ngagai
nstwhi
chmodul
e
o whi
chst
udent
shav
ebeenassessedi
nwhi
chmodul
es
Var
iousmember
sofst
affatauni
ver
sit
ywi
l
lbeent
eri
ngdat
asuchasabov
eint
oadat
abase
sy
stem.Fori
nst
ance,dat
arel
evantt
o cour
ses and modul
es may be ent
ered by t
he
admi
nist
rat
orsi
nacademi
cdepar
tment
s,par
ti
cul
arl
ythei
renr
olment
soncour
sesandmodul
es,
1
Okor
onkwoM.C.Cos124
maybeent
eredbyst
affatacent
ral
regi
str
y.
Oncet
hedat
aisent
eredi
ntot
hedat
abasei
tmaybeut
il
isedi
nav
ari
etyofway
s.Forexampl
e,a
compl
eteandaccur
atel
i
stofenr
oll
edst
udent
smaybeusedt
ogener
atemember
shi
precor
ds
f
ort
hel
ear
ningr
esour
cecent
re;
itmaybeusedasacl
aimt
oeducat
ionalaut
hor
it
iesbyst
udent
orasani
nputi
ntoat
imet
abl
i
ngsy
stem whi
chmi
ghtat
temptt
oopt
imi
ser
oom ut
il
isat
ion
acr
ossauni
ver
sit
ycampus.
Dat
a
Wedef
ineddat
aasf
act
sorposi
ti
veasser
ti
onsaboutsomedomai
nofdi
scour
se(
int
erest
).
Accor
dingt
othi
sdef
ini
ti
onadat
abasei
sal
ogi
cal
l
yor
gani
sedcol
l
ect
ionoff
act
saboutsome
domai
n.
A dat
um – auni
tofdat
a– i
sasy
mbolorasetofsy
mbol
swhi
chi
susedt
orepr
esent
somet
hing.Thi
srel
ati
onshi
pbet
weensy
mbol
sandwhatt
heyr
epr
esenti
stheessenceofwhat
wemeanbyi
nfor
mat
ion.Hence,
inf
ormat
ioni
sint
erpr
eteddat
a–dat
asuppl
i
edwi
thsemant
ics.
o Dat
aisdi
sti
nctpi
ecesofi
nfor
mat
ion,usual
l
yfor
mat
ted(
arr
anged)i
naspeci
alway
.Al
l
sof
twar
eisdi
vi
ded i
ntot
wo gener
alcat
egor
ies:dat
a and pr
ogr
ams.Pr
ogr
amsar
e
col
l
ect
ionsofi
nst
ruct
ionsf
ormani
pul
ati
ngdat
a.
o Dat
acanexi
sti
nav
ari
etyoff
orms-
-asnumber
sort
extonpi
ecesofpaper
,asbi
tsand
by
tesst
oredi
nel
ect
roni
cmemor
y,orasf
act
sst
oredi
naper
son'
smi
nd.
o St
ri
ctl
yspeaki
ng,dat
aist
hepl
uralofdat
um,asi
ngl
epi
eceofi
nfor
mat
ion.I
npr
act
ice,
howev
er, eusedat
peopl aasbot
hthesi
ngul
arandpl
ural
for
m oft
hewor
d.
o Dat
athatr
esi
desi
naf
ixedf
iel
dwi
thi
nar
ecor
dorf
il
eiscal
l
edst
ruct
ureddat
a.Thi
s
i
ncl
udesdat
acont
ainedi
nRel
ati
onal
dat
abasesandSpr
eadsheet
s.
o St
ruct
ureddat
afi
rstdependsoncr
eat
ingadat
amodel– amodeloft
het
ypesof
busi
nessdat
athatwi
l
lber
ecor
dedandhowt
heywi
l
lbest
ored,
processedandaccessed.
Thi
sincl
udesdef
ini
ngwhatf
iel
dsofdat
awi
l
lbest
oredandhowt
hatdat
awi
l
lbest
ored:
dat
aty
pe(
numer
ic,
cur
rency
,al
phabet
ic,
name,
dat
e,addr
ess)andanyr
est
ri
cti
onsont
he
dat
ainput(
numberofchar
act
ers;
rest
ri
ctedt
ocer
tai
nter
mssuchasMr
.,Ms.orDr
.;M or
F)
.
o St
ruct
ureddat
ahast
headv
ant
ageofbei
ngeasi
l
yent
ered,
stor
ed,quer
iedandanal
yzed.
Atonet
ime,becauseoft
hehi
ghcostandper
for
mancel
i
mit
ati
onsofst
orage,memor
y
andpr
ocessi
ng,r
elat
ionaldat
abasesandspr
eadsheet
susi
ngst
ruct
ureddat
awer
ethe
onl
ywayt
oef
fect
ivel
ymanagedat
a.Any
thi
ngt
hatcoul
dn'
tfi
tint
oat
ight
lyor
gani
zed
2
Okor
onkwoM.C.Cos124
st
ruct
urewoul
dhav
etobest
oredonpaperi
naf
il
ingcabi
net
I
nfor
mat
ion
Theconceptofi
nfor
mat
ioni
sanext
remel
yvagueone;
itsopent
omanydi
ff
erenti
nter
pret
ati
ons
(
Stamper
,1989)
.Oneconcept
ionpopul
ari
nthecomput
ingl
i
ter
atur
eist
hati
nfor
mat
ionr
esul
ts
f
rom t
hepr
ocessi
ngofdat
a:t
heassembl
y,anal
ysi
sorsummar
isat
ionofdat
a.Thi
sconcept
ion
ofi
nfor
mat
ionasanal
ogoust
ochemi
caldi
sti
l
lat
ioni
susef
ul,
buti
gnor
est
hei
mpor
tantpl
aceof
humani
nter
pret
ati
oni
nanyunder
standi
ngofi
nfor
mat
ion.
Onecanar
guet
hatbot
hdat
aandi
nfor
mat
ionar
eembodi
edi
ntheconceptofasi
gn,
hence
si
gnsandsi
gn-
syst
emsar
ethef
undament
alst
uffofdat
abasesy
stems.
Asi
gni
sany
thi
ngt
hati
ssi
gni
fi
cant
.Inasense,ev
ery
thi
ngt
hathumansdoi
ssi
gni
fi
cantt
o
somedegr
ee.Thewor
ldwi
thi
nwhi
chhumansf
indt
hemsel
vesi
sresonant
(ri
ch)wi
thsi
gn-
sy
stems.A si
gn-
syst
em i
sanyor
gani
sedcol
l
ect
ionofsi
gns.Ev
ery
dayspokenl
anguagei
s
pr
obabl
ythemostr
eadi
l
yaccept
edandcompl
exexampl
eofasi
gn-
syst
em.Si
gnshowev
erexi
st
i
nmostot
herf
ormsofhumanact
ivi
ty,si
ncesi
gnsar
ecr
it
icalt
othepr
ocessofhuman
communi
cat
ionandunder
standi
ng.
Dat
abase
Adat
abasei
susual
l
yconsi
der
edasanor
gani
sedcol
l
ect
ionofdat
awhi
chi
smeantt
orepr
esent
some uni
ver
seofdi
scour
se.I
tist
her
ef e,an or
or gani
zed,machi
ne-
readabl
e col
l
ect
ion of
sy
mbol
s,t
obei
nter
pret
edasat
rueaccountofsomeent
erpr
ise.I
tismachi
ne-
updat
abl
etoo,
andsomustal
sobeacol
l
ect
ionofv
ari
abl
es.I
tist
ypi
cal
l
yav
ail
abl
etoacommuni
tyofuser
s,
wi
thpossi
blyv
ary
ingr
equi
rement
s.
Theor
gani
zed,machi
ne-
readabl
ecol
l
ect
ionofsy
mbol
siswhaty
ou“
see”i
fyou“
lookat
”
adat
abaseatapar
ti
cul
arpoi
nti
nti
me.I
tist
obei
nter
pret
edasat
rueaccountoft
heent
erpr
ise
att
hatpoi
nti
nti
me.Ofcour
sei
tmi
ghthappent
obei
ncor
rect
,incompl
eteori
naccur
ate,so
per
hapsi
tisbet
tert
osayt
hatt sbel
heaccounti i
evedt
obet
rue.
Theal
ter
nat
ivev
iewofadat
abaseasacol
l
ect
ionofv
ari
abl
esr
efl
ect
sthef
actt
hatt
heaccount
(
stor
yordescr
ipt
ion)oft
heent
erpr
isehast
ochangef
rom t
imet
oti
me,dependi
ngont
he
f
requencyofchangei
nthedet
ail
swechooset
oincl
udei
nthataccount
.
Col
l
oqui
all
y,i
ngener
aluse,
thet
erm dat
abaseof
tenmeans:
Alar
gecol
l
ect
ionofdat
a
managedbyasi
ngl
eor
gani
zat
ion.
Wi
thi
ncomput
ersci
ence,
adat
abaset
ypi
cal
l
ymeansapr
ogr
am t
hatpr
ovi
dest
hef
oll
owi
ng
ser
vices:
3
Okor
onkwoM.C.Cos124
o St
orageofst
ruct
ureddat
a
o Accessandupdat
eoft
hisdat
a
o Sear
chi
ngoft
hisdat
a
o Guar
ant
eeACI
DAt
omi
c,Consi
stent
,Isol
ati
on,
Dur
abi
l
ityt
ransact
ions
o Ensur
esdat
adoesn’
tgetl
ostorov
erwr
it
ten
o Admi
nist
rat
ionofdat
a
Accesscont
rol
,backups
…al
loft
hisatl
argescal
eGi
gaby
tesandTer
aby
tesofdat
a
SomekeyConcept
s/Ter
ms
Dat
a
o Dat
aisr
aw,
unor
gani
zedf
act
sthatneedt
obepr
ocessed.
I
nfor
mat
ion
o Whendat
aispr
ocessed,
organi
zed,
str
uct
uredorpr
esent
edi
nagi
vencont
extsoast
o
makei
tusef
ul,
iti
scal
l
edi
nfor
mat
ion.
Dat
abase
o ADat
abasei
sacol
l
ect
ionofi
nter
-r
elat
eddat
a.
DBMS(
Dat
abaseManagementSy
stem)
o ADBMSi
sacol
l
ect
ionofi
nter
-r
elat
eddat
aandsetofpr
ogr
amst
omani
pul
atet
hose
dat
a.
o DBMS=Dat
abase+Setofpr
ogr
ams
Met
adat
a
o Met
adat
aisdat
aaboutdat
a.
o Dat
asuchast
abl
ename,
col
umnname,
dat
aty
pe,
aut
hor
izeduseranduseraccess
pr
ivi
l
egesf
oranyt
abl
eiscal
l
edmet
adat
afort
hatt
abl
e.
Dat
adi
cti
onar
y
o Dat
adi
cti
onar
yisani
nfor
mat
ionr
eposi
tor
ywhi
chcont
ainsmet
adat
a.
o I
tisusual
l
yapar
toft
hesy
stem cat
alog.
Dat
awar
ehouse
o Dat
awar
ehousei
sani
nfor
mat
ionr
eposi
tor
ywhi
chst
oreddat
a.
o I
tisdesi
gnt
ofaci
l
itat
erepor
ti
ngandanal
ysi
s.
Fi
eld
o Af
iel
disachar
act
erorgr
oupofchar
act
erst
hathav
easpeci
fi
cmeani
ng.
o I
tisal
socal
l
edadat
ait
em.I
tisr
epr
esent
edi
nthedat
abasebyav
alue.
o ForExampl
ecust
omeri
d,name,
soci
etyandci
tyar
eal
lfi
eldsf
orcust
omerDat
a.
4
Okor
onkwoM.C.Cos124
Recor
d
o Ar
ecor
disacol
l
ect
ionofl
ogi
cal
l
yrel
atedf
iel
ds.
o Forexampl
es,
col
l
ect
ionoff
iel
ds(
id,
name,
soci
ety&ci
ty)f
ormsar
ecor
dforcust
omer
.
St
ruct
uredDat
a,SQLandUnst
ruct
uredDat
a
Structureddat aisoftenmanagedusi ngSt ruct
uredQuer yLanguage( SQL)–apr ogrammi ng
l
anguagecr eatedformanagingandquer yi
ngdat ainrelati
onaldat abasemanagementsy stems.
Ori
ginal l
ydev el
opedbyI BM intheear l
y1970sandl aterdev el
opedcommer ci
all
ybyRel ational
Softwar e,I
nc.(nowOr acl
eCorporation)
.
Str
uct ureddat awasahugei mpr ovementov erstri
ctl
ypaper -basedunst ruct
uredsy st
ems,but
l
ifedoesn' talwaysfitint
oneatl itt
leboxes.Asar esult,t
hest ructureddataalway shadt obe
supplement edbypaperormi crofil
m storage.Ast echnologyper formancehascont inuedt o
i
mpr ov e,and pr i
ces hav e dropped,i twas possi bl et o bring into computing sy st
ems
unstructuredandsemi -st
ruct
ureddat a.
Unstructureddatai
sallthosethingsthatcan'
tbesor eadi
lyclassi
fi
edandfiti
ntoaneatbox:
photosandgr aphi
cimages,vi
deos, st
reamingi
nstr
umentdat a,
webpages,pdffi
l
es,Power
Point
presentati
ons,emai
ls,
blogentr
ies,wiki
sandwor dprocessi
ngdocuments.
Semi -
str
uctur
eddataisacr ossbetweenthet wo.I
tisatypeofstructur
eddat
a,butlacksthe
str
ictdatamodelstr
uctur
e.Wi t
hsemi-st
ructur
eddata,t
agsorothertypesofmarkersareused
toidenti
fycert
ainelementswithi
nthedat a,butthedatadoesn’
thav earigi
dstructur
e.For
example:,
o Wordpr ocessingsof t
warenowcani ncl
udemet adatashowingt heaut hor'
snameandt he
datecreated,wit
ht hebulkoft hedocumentj ustbeingunstruct
ur edtext.
o Emails havet he sender ,recipient
,date,time and ot herfixed fields added t
ot he
unstr
uctureddataoft heemai l messagecontentandanyat t
achment s.
o Photosorot hergraphicscanbet aggedwithkey wordssuchast hecreator,dat
e,l
ocat
ion
andkey words,maki ngitpossibletoorgani
zeandl ocategraphi
cs.
XMLandot
hermar
kupl
anguagesar
eof
tenusedt
omanagesemi
-st
ruct
ureddat
a.
St
ruct
uredDat
aTechnol
ogy
SQLhasbeen ast andar d oft heAmer ican Nat ionalSt andar dsI nsti
tutesi nce1986.I tis
managedbyI nternationalCommi t
teef orInf or
mat ionTechnol ogySt andards( INCI TS)Techni cal
Commi ttee DM 32 – Data Management and I
nterchange
(ht
tp://
standards.incits.
org/a/public/group/ dm32) .Thecommi t
teehast wot askgr oups,one
fordatabasesandt heot herformet adat a.HP,CA,I BM,Mi crosof t
,Oracle,Sy base( SAP)and
Teradataallparti
cipate,aswel l assev eralfederal gov ernmentagenci es.
Thedat abasepr ojectsar el i
stedher e-ht t
p:// www. inci t
s.or
g/tc_project s/
dm32. 2.pdf-
andt heMet adatapr ojectsher e-ht tp:/
/ www. incits.org/t
c_ pr oject
s/dm32. 2.pdf .Bot hoft he
commi tt
eepr ojectdocument shav elinkst of urt
heri nfor mationoneachpr oject.
SQLbecameanI nternationalOr gani zat
ionf orSt andar ds( I
SO)st andar di n1987.The
publi
shed st andar ds ar e av ail
ablef or pur chase f r
om t he ANSI eSt andar ds St or
e–
webstore.ansi.
org–undert heINCI TS/ISO/ IEC9075cl assif
icat i
on.
Thephr
ase"
unst
ruct
ureddat
a"usual
l
yref
erst
oinf
ormat
iont
hatdoesn'
tresi
dei
nat
radi
ti
onal
5
Okor
onkwoM.C.Cos124
row-col
umndatabase.Asy oumi
ghtexpect
,it
'
stheopposi
teofst
ruct
ureddat
a--t
hedat
a
stor
edinfi
eldsi
nadatabase.
Unstructur
eddat af i
l
esof t
eni ncl
udet extandmul ti
medi acontent.Examplesincludee-
mail
messages,wor dpr ocessingdocument s,videos,photos,audiofil
es,present
ati
ons,webpages
andmanyot herki
ndsofbusi nessdocument s.Notethatwhilethesesortsoffi
lesmayhavean
i
nternalstruct
ure,
theyar estil
lconsider
ed" unst
ruct
ured"becauset hedatatheycontai
ndoesn'
t
fi
tneatlyinadatabase.
Expert
sesti
matet hat80to90percentofthedat
ainanyorganizat
ionisunst
ruct
ured.Andthe
amountofunstructureddat
ainenterpr
isesi
sgrowi
ngsigni
ficantl
y--oft
enmanyt i
mesf ast
er
thanstr
uct
ureddatabasesaregr
owing.
Mi
ningUnst
ruct
uredDat
a
Manyor ganizat
ionsbeli
evethattheirunstructureddat astoresincludeinfor
mat ionthatcould
hel
pt hem makebet t
erbusinessdeci si
ons.Unf ortunatel
y,it'
softenv erydif
ficulttoanalyze
unstr
uctureddata.Tohelpwiththeproblem, organizati
onshav eturnedtoanumberofdi ff
erent
soft
waresol uti
onsdesignedtosear chunst ructureddat aandext ractimportantinformati
on.
Theprimar ybenefi
tofthesetoolsistheabi l
i
tytogl eanactionableinfor
mat i
ont hatcanhelpa
busi
nesst osucceedinacompet it
iveenvir
onment .
Unst
ruct
uredDat
aandBi
gDat
a
Asment i
onedabove,unstructureddat aist heopposit
eofst ruct ur
eddat a.Str
uctureddat a
generall
yresi
desinar elat
ionaldat abase,andasar esult
,itissomet imescal l
ed" r
elati
onal
data."Thi
stypeofdatacanbeeasi l
ymappedi nt
opre-
designedfields.Forexample,adat abase
designermaysetupfiel
dsforphonenumber s,zi
pcodesandcr editcardnumber sthataccepta
certai
nnumberofdi git
s.Structureddat ahasbeenorcanbepl acedi nfi
eldsli
ket hese.By
contrast
,unstr
uct
ureddataisnotr el
ati
onalanddoesn'tfiti
ntothesesor tsofpre-def
ineddat a
model s.
Inaddit
iont ostr
ucturedandunst r
uctureddata,t
here'salsoat hi
rdcategor
y:semi -
str
uct
ured
data.Semi-st
ruct
ureddataisi nf
ormationthatdoesn'tresi
deinar el
ati
onaldatabasebutthat
doeshav esomeor gani
zat
ionalproperti
esthatmakei teasiertoanaly
ze.Exampl esofsemi-
str
uctureddatamightincl
udeXMLdocument sandNoSQLdat abases.
Thet er
m" bigdat
a"isclosel
yassoci
atedwit
hunst ructur
eddata.Bi
gdatar ef
erstoextremel
y
l
argedat aset
sthataredi f
fi
cul
ttoanalyzewit
ht raditi
onalt
ools.Bi
gdat acanincludeboth
str
ucturedandunstr
uctureddat
a,butI
DCesti
mat est hat90per
centofbigdataisunstr
uctur
ed
data.Manyofthetool
sdesignedtoanaly
zebi
gdat acanhandleunstr
uctur
eddata.
Dat
abaseVendor
s
o Oracl
eCorporat
ion–OracleDatabase11g(Pr
opriet
ary
);MySQL(GPLorPr
opr
iet
ary
)
o Sybase–AdaptiveDat
abaseSer v
er;SQLAnywhere(Pr
opri
etar
y)
o IBM –DB2,Inf
ormixDynamicServer(Pr
opr
iet
ary)
6
Okor
onkwoM.C.Cos124
o Fi
leMaker–Fi l
eMaker(
Pr opr
iet
ary
)
o Micr
osoft–SQLSer ver
,Access
o Hewlet
t-Packard–HPNonSt opSQL( Propr
iet
ary
)
o Apache–ApacheDer by(ApacheLicense)
o Postgr
eSQLGl obal
DevelopmentGroup–Post greSQL(
Post
greSQLopensour
cel
i
cense)
Al
loft
heabovedatabasesworkwit
hMi cr
osoftWi
ndows.Al
lexceptt
heMicrosof
tpr
oduct
s
al
sosuppor
tatl
eastoneotheroper
ati
ngsy st
em (
MacOSX,LinuxorUni
x).
Fi
le-basedSystem
TheChar act
erist
icsofConv
ent
ionalf
il
e-basedsy
stem
DataRedundancy
o Of tent hesamei nf ormat ioni sdupl icatedi ndi fferentf i
les.Thi sleadst odat ar edundancy .
o t her edundancyr esul tsinmemor ywast age
o Forexampl e, consi derthatsomecust omer smayhav et woki ndsofaccount s: sav ingand
curr ent .Int hi scase, dataaboutcust omer s-name, addr ess, e-mai l
,cont actnumber–wi ll
bedupl icat edi nf i
lef orsav ingaccount sandf i
lef orcur rentaccount s.Thi sl eadst o
requi rementofhi gherst or agespace.I not herwor ds, samei nformat i
onwi ll best or edi n
twodi ffer entl ocat ions( files).And, itwast esmemor y.
DataI nconsi stency
o Duet odat ar edundancy ,iti spossi bl et hatdat amaynotbei nconsi st entst at e.
o Forexampl e, consi derthatanaddr essofsomecust omerchanges.And, thatcust omer
hasbot hki ndsofaccount s.Now, i
ti spossi bl
et hatt hischangedaddr essi supdat edi n
onlyonef i
l
e, leavingaddr essi not herf ileasi tis.Asar esul toft his,samecust omerwi l
l
hav et wodi ff erentaddr essesi ntwodi ffer entf i
les,maki ngdat ai nconsi stent .
Diff
icultyi nAccessi ngDat a
o Accessi ngdat aisnotconv enientandef ficientinf il
epr ocessi ngsy stem.
o Forexampl e, suppose, ther ei sapr ogr am t of i
ndi nfor mat ionaboutal lcust omer s.But ,
whati ft her ei saneedt of indoutal l cust omer sf rom somepar ti
cularci t
y.I nt hiscase,
ther ear et wochoi cesher e: One, findoutal lcust omer susi ngav ail
abl epr ogr am, andt hen
extractt heneededcust omer smanual ly .Second, dev el
opnewpr ogr am t ogetr equi red
i
nf or mat ion.Bot hopt ionsar enotsat i
sf act ory.
o Foreachandev er ydifferentki ndofdat aaccess, separ atepr ogramsar er equi red.Thi sis
neitherconv enientnoref ficient .
LimitedDat aShar ing
o Dat aar escat teredi nvar i
ousf iles.
o Di fferentf i
lesmayhav edi fferentf or mat s.Andt hesef i
lesmaybest oredi ndi f fer ent
folder s( di rect ories)maybeofdi ffer entcomput ersofdi fferentdepar tment s.
o So, duet ot hi sdat aisolat i
on, itisdi fficul ttoshar edat aamongdi fferentappl icat ions.
Int
egr i
tyPr obl ems
o Dat ai nt egr itymeanst hatt hedat acont ai nedi nt hedat abasei sbot hcor rectand
consi st ent .Fort hi spur pose, thedat ast or edi ndat abasemustsat i
sf ycer taint y pesof
const raint s( rules) .
o Forexampl e, abal ancef oranyaccountmustnotbel esst hanzer o.Suchconst rai ntsar e
enf orcedi nt hesy stem byaddi ngappr opr i
atecodei nappl icat ionpr ogr ams.But , when
newconst raint sar eadded, suchasbal anceshoul dnotbel esst hanRs.5000, appl icati
on
progr amsneedt obechanged.But , iti
snotaneasyt askt ochangepr ogr amswhenev er
requi red.
Atomi cityPr obl ems
o Anyoper ationondat abasemustbeat omi c.Thi smeans, oper ationcompl et esei ther
100%or0%.
7
Okor
onkwoM.C.Cos124
Adv
ant
agesofDat
abase(
Pur
poseofdat
abasesy
stem)
Mini
malDat aRedundancy( Duplicati
on)
o Duet ocent rali
zeddat abase, i
tispossibl etoavoi
dunnecessar ydupl
i
cati
onof
i
nformat i
on.
o Thisl eadst or educedat ar edundancy.
o Itprev entsmemor ywast age.
o Italsor educesext r
apr ocessingtimet ogetr equir
eddata.
SharedDat a
o Allaut hori
zeduserandappl i
cati
onpr ogr am cansharedatabaseeasi
ly.
DataConsist ency
o Dat ainconsi stencyoccur sduet odat ar edundancy.
o Wi threduceddat ar edundancysucht ypeofdat ainconsi
stencycanbeelimi
nat
ed.
o Thisr esultsi nimpr oveddat aconsistency .
DataAccess
o DBMSut il
izesav ari
etyoft echni
quest or etr
ievedata.
o Requi reddat acanber et
rievedbypr ovidingappropri
atequerytotheDBMS.
o Thus,
dat
acanbeaccessedi
nconv
eni
entandef
fi
cientmanner
.
Dat
aInt
egri
ty
o Dataindatabasemustbecor rectandconsistent
.
o So,datastoredi
ndat abasemustsat i
sfycert
aint
ypesofconst
rai
nts(r
ules)
.
o DBMSpr ovidesdi
fferentwaystoimpl ementsuchty
peofconstr
aint
s(rul
es).
o Thisimprovesdataintegri
tyi
nadat abase.
8
Okor
onkwoM.C.Cos124
DataSecur it
y
o Dat abaseshoul dbeaccessi bletouserinali
mitedway .
o DBMSpr ovi
deswayt ocont roltheaccesstodataf ordif
ferentuseraccor
dingtothei
r
requirement .
o I tpreventsunauthorizedaccesst odat
a.
o Thus, securit
ycanbei mpr oved.
ConcurrentAccess
o Mul tipleusersareallowedt oaccessdat asimultaneously.
o Concur rentaccesstocent rali
zeddatacanbeal l
owedundersomesuper vi
sion.
o Thi sresul t
sinbetterperformanceofsy stem andf ast
erresponse.
GuaranteedAt omici
ty
o Anyoper at
ionondat abasemustbeat omic.Thismeans, operati
onmustbeexecut ed
eit
her100%or0%.
o Thi sty peofatomicityisguar anteedi
nDBMS.
Dat
abaseAppl
icat
ions
Dat
abasesandor
gani
zat
ions
Anymedi
um t
olar
gesi
zedor
gani
zat
iont
odayusedat
abases.Busi
nessesj
ustdonotscal
e
wi
thoutusi
ngt
hem.Onceabusi
nessget
slar
gert
hant
he“
ma&pa”st
age,
itst
art
stoneedone
ormor
edat
abasest
omanaget
hebusi
ness
Dat
abasesar
eessent
ial
forsuchf
unct
ionsas:
Pay
rol
l
,Inv
ent
orymanagement
,Sal
es,
Orderf
ulf
il
ment
,Cust
omermanagement
,
Account
ing
AreasofAppl icat i
onandf unctions
Airl
inesandr ailway s
o Ai rli
nesandr ail
way suseonl i
nedat abasesf orr eser
vation, andf ordisplayi
ngt he
schedul ei nformat i
on.
Banki ng
o Banksusedat abasesf orcust omeri nquiry,accounts,loans, andot hert r
ansact i
ons.
Educat ion
o School sandcol l
egesusedat abasesf orcourser egi
stration, r
esult,andot herinformati
on.
Telecommuni cat i
ons
o Tel ecommuni cat
iondepar tment susedat abasest ostor einformat i
onaboutt he
communi cationnet work, t
elephonenumber s,recordofcal l
s,forgener ati
ngmont hlybi
ll
s,
etc.
Credi tcardt r
ansact i
ons
o Dat abasesar eusedf orkeepi ngt rackofpur chasesoncr editcardsinor dertogener ate
mont hlyst atement s.
E-commer ce
o I ntegrationofhet erogeneousi nformat ionsour ces(forexampl e,catalogs)forbusi ness
Heal thcar e
o Dat abasesar eusedf ormai ntainingt hepat i
enthealthcar edet ai
lsinhospi t
als.
Digitalli
br ar
iesanddi gi
talpublishi
ng
o Dat abasesar eusedf ormanagementanddel i
veryoflargebodi esoft extualand
mul ti
medi adat a.
Fi
nance
o Dat abasesar eusedf orstoringi nformat i
onsuchassal es, purchasesofst ocksand
9
Okor
onkwoM.C.Cos124
bondsordat ausefulf
oronli
netrading.
Sal
es
o Dat abasesar eusedtost
oreproduct ,
customerandtr
ansact
iondet
ail
s.
Humanresour ces
o Or ganizati
onsusedatabasesforstoringi
nfor
mat i
onaboutt
hei
remployees,
sal
ari
es,
benefi
ts,taxes,andf
orgenerat
ingsalarychecks.
Rel
ati
onalDat
abases
Ar
elat
ionaldat
abasei
sonewhosesy
mbol
sar
eor
gani
zedi
ntoacol
l
ect
ionofr
elat
ions.Fi
gur
e1.
2
conf
ir
mst
hatt
heexampl
eswehav
eal
readyseenar
einf
actr
elat
ions,
depi
ctedi
ntabul
arf
orm.
I
ndeed,
accor
dingt
oFi
gur
e1.
1,t
her
elat
iondepi
ctedi
nFi
gur
e1.
2ist
hecur
rentv
alueoft
hev
ari
abl
e
ENROLMENT.
St
udent
Id Name Cour
seI
d
S1 Anne C1
S1 Anne C2
S2 Boris C1
S3 Cindy C3
S4 Devinder C1
Fi
gur
e1.
1:Ar
elat
ion,showni
ntabul
arf
orm
Fi
gur
e1.
2:Ar
elat
ion,
showni
ntabul
arf
orm
Happi
l
y,t
hev
isual(
tabul
ar)r
epr
esent
ati
onwehav
ebeenusi
ngt
husf
ari
ssui
tedpar
ti
cul
arl
ywel
lto
r
elat
ionaldat
abases:somuchsot
hatmanypeopl
euset dt
hewor abl
easanal
ter
nat
iv or
et el
ati
on.The
l
anguageSQLi
npar
ti
cul
arusest
hatt
erm,soi
nthecont
extofr
elat
ionalt
heor
yiti
sconv
eni
entand
j
udi
cioust
ost
ickwi
thr
elat
ionf
ort
het
heor
eti
calconst
ruct
,al
l
owi
ngSQL’
sdev
iat
ionsf
rom r
elat
ional
t
heor
ytobenot
edasdi
ff
erencesbet
weent
abl
esandr
elat
ions.
Rel
ati
oni
saf
ormalt
ermi
nmat
hemat
icsi
npar
ti
cul
ar,i
nthel
ogi
calf
oundat
ionofmat
hemat
ics.I
t
appeal
stot
henot
ionofr
elat
ionshi
psbet
weent
hings.Mostmat
hemat
icalt
ext
sfocusonr
elat
ions
i
nvol
vi
ngt
hingst
akeni
npai
rsbutourexampl
eshowsar
elat
ioni
nvol
vi
ngt
hingst
akent
hreeatat
ime
and,asweshal
lsee,r
elat
ionsi
ngener
alcanr
elat
eanynumberoft
hings(
and,asweshal
lsee,t
he
numberi
nquest
ioncanev
enbel
esst
hant
wo,
maki
ngt
het
ermr
elat
ionseem somewhati
nappr
opr
iat
e).
Anat
omyofaRel
ati
on
10
Okor
onkwoM.C.Cos124
Fi
gur
e1.
3showst
het
ermi
nol
ogyweuset
oref
ert
opar
tsoft
hest
ruct
ureofar
elat
ion
Fi
gur
e1.
3:Ar
elat
ion,
showni
ntabul
arf
orm
Becauseoft
hedi
sti
nct
ionIhav
enot
edbet
weent
het
ermsr
elat
ionandt
abl
e,wepr
efernott
ouset
he
t
ermi
nol
ogyoft
abl
esf
ort
heanat
omi
calpar
tsofar
elat
ion.Weusei
nst
eadt
het
ermspr
oposedbyE.
F.
Codd,
ther
esear
cherwhof
ir
stpr
oposedr
elat
ional
theor
yasabasi
sfordat
abaset
echnol
ogy
,in1969.
Tr
ytogetusedt
otheset
erms.Youmi
ghtnotf
indt
hem v
eryi
ntui
ti
ve.Thei
rcount
erpar
tsi
nthet
abul
ar
r
epr
esent
ati
onmi
ghthel
p:
r
elat
ion :
tabl
e
n-
( )
tupl
e :
row
at
tri
but
e :
col
umn
Al
so(
asshowni
nFi
gur
e1.
3):
Thedegr
eei
sthenumberofat
tr
ibut
es.
Thecar
dinal
it
yist
henumberoft
upl
es.
Or
gani
zat
ionofdat
abases
o Adat
abasecont
ainsasetoft
abl
es
o At
abl
econt
ainsasetofr
owseachr
owr
epr
esent
sasetofr
elat
eddat
ait
ems
o Eachdat
ait
em bel
ongst
oacol
umn
Associ
atedwi
that
abl
eisaschema
Theschemadescr
ibest
heki
ndofdat
afoundi
neachcol
umn
Thef
oll
owi
ngar
ebasi
cdat
aty
pes:
int
eger
,fl
oat
,st
ri
ng,
dat
e,et
c.
11
Okor
onkwoM.C.Cos124
Dat
abasecont
ainst
abl
eswhi
chi
smadeupofr
owsandschema:
Dat
abase Vi
deoTi
tl
e Vi
deoUpl
oader #v
iews
t
abl
eVi
d_I
D
1 Ghengi
sKhanv
sEast
er ni
cepet
er 641698
Bunny
2 St
ranger
s,agai
n WongFuPr
oduct
io 948102
ns
3 Copadel
ReyApl
ast
ada 1unodos 2405925
4 Al
i
enFound? Ray
Wil
l
iamJohnson 741425
Eachhor
izont
all
i
nei
sar
ow
Exampl
e:(
2,“
Str
anger
s,agai
n”,
WongFuPr
oduct
ions,
948102)
Eachv
ert
ical
li
nei
sacol
umn
Exampl
e:Vi
deoTi
tl
eisacol
umn
Uni
queI
dent
if
ier
Wi
thi
nat
abl
e,oneoft
hecol
umnst
ypi
cal
l
yisauni
quei
dent
if
ier
Whati
sani
dent
if
ier
?
o I
tisanumberorst
ri
ngt
hati
sguar
ant
eedt
obedi
ff
erentf
oreachr
ow
o Thati
s,t
hei
dent
if
ierf
oragi
venr
owi
sguar
ant
eedt
onotbeusedf
oranyot
herr
ow
o Thati
s,t
hei
dent
if
ieri
sguar
ant
eedt
obeuni
queacr
ossal
lrows
o Thi
sper
mit
seachr
owt
ohav
edat
athati
sthesameasdat
ainot
herr
ows,
butst
il
lbe
abl
etot
ell
oner
owapar
tfr
om anot
her
o I
ndat
abases,
thi
suni
quei
dent
if
ieri
sknownasakey
o Eacht
abl
ety
pical
l
yhasakeyknownast
hepr
imar
ykey
I
ncl
assexampl
e
Useofkey
s
Oneadv
ant
ageofkey
sist
heyal
l
owonet
abl
etor
efer
encedat
ainanot
hert
abl
e
Vi
d_I Vi
deoTi
tl
e Vi
deoUpl
oader #v
iews
D
1 Ghengi
sKhan ni
cepet
er 641698
v
sEast
er
Bunny
12
Okor
onkwoM.C.Cos124
2 St
ranger
s, WongFuPr
oduct
ion 948102
agai
n s
3 Copadel
Rey 1unodos 2405925
Apl
ast
ada
4 Al
i
enFound? Ray
Wil
l
iamJohnso 741425
n
I
nthet
abl
eabov
e,don’
treal
l
ywantt
ost
oret
hest
ri
ngnami
ngt
hev
ideoupl
oader
.Inst
ead,
real
l
y
wantar
efer
encet
othet
abl
ehol
dingst
atsabouteachupl
oader
:
Useofkey
s UserName #v
ideos Joi
ned
(
cont
’d)
UL_
ID upl
oaded Dat
e
100 Ni
cepet
er 5 12/
25/
2008
101 WongFuPr
oduct
ions 1 5/
21/
2007
102 Ray
Wil
l
iamJohnson 3 3/
1/2010
103 1unodos 7 2/
28/
2009
Schemas
Par
tofcr
eat
ingadat
abasei
sdet
ermi
ningwhatki
ndofdat
aeachcol
umnhol
ds
o Thi
sinv
olv
esmodel
i
ngar
eal
wor
ldsi
tuat
ioni
ndat
a
o Usual
l
y,t
hesameki
ndsofbasi
cdat
aty
pesar
eav
ail
abl
easwehav
eseensof
art
hese
ar
e:
o I
nteger
,fl
oat
,st
ri
ng,
Bool
ean,
Also:
dat
es,
time,
arbi
tr
arypr
eci
sionnumber
s,bi
tfi
eldsand
of
tenbl
obsoft
ext
o Whencr
eat
ingat
abl
e,y
oumustdet
ermi
newhi
chcol
umni
sassoci
atewi
thwhi
chdat
a
t
ype
Vi
d_I
D Vi
deoTi
tl
e Vi
deoUpl
oader #v
iews
1 Ghengi
sKhanv
sEast
er ni
cepet
er 641698
Bunny
2 St
ranger
s,agai
n WongFuPr
oduct
ions 948102
3 Copadel
ReyApl
ast
ada 1unodos 2405925
4 Al
i
enFound? Ray
Wil
l
iamJohnson 741425
13
Okor
onkwoM.C.Cos124
Cont
ent
sofaDat
abase
Dat
abaseconsi
stsof
:a.UserDat
ab.Met
adat
ac.I
ndex
esd.Appl
i
cat
ionmet
adat
a
UserDat
a
1.User
swor
kwi
thdat
abasedi
rect
lybyent
eri
ng,
updat
ingandv
iewi
ngdat
a.
2. Forourpur
poses,
dat
awi
l
lbegener
all
yst
or nt
edi abl
eswi
thsomer
elat
ionshi
psbet
weent
abl
es.
3. Eacht
abl ecol
ehasoneormor umns.Asetofcol
umnsf
or abaser
msadat ecor
d.
Met
adat
a
Recal
lthatadat
abasei
ssel
fdescr
ibi
ng,
ther
efor
e,Met
adat
acanbedescr
ibedas:
i
. Dat
aaboutdat
a.
i
i
. Dat
athatdescr
ibehowuserdat
aar
est
oredi
nter
msoft
abl
ename,
col
umnname,
dat
aty
pe,
l
engt
h,pr
imar
ykey
s,et
c.
i
i
i.Met
adat
aar
ety
pical
l
yst
or nSy
edi stem t
abl
esorSy
stem Cat
alogandar
ety
pical
l
yonl
ydi
rect
ly
accessi
blebyt
heDBMSorbyt
hesy
stem admi
nist
rat
or.
Hav
eal
ookatt
heDat
abaseDocument
erf
eat
ureofMSAccess(
undert
het
ool
smenu,
chooseAnal
yze
andt
henDocument
er)
.Thi
stool
quer
iest
hesy
stem t
abl
est
ogi
veal
lki
ndsofMet
adat
afort
abl
es,
etc.i
n
anMSAccessdat
abase.
I
ndexes
I
nkeepi
ngwi
thourdesi
ret
opr
ovi
deuser
swi
thsev
eral
dif
fer
entv
iewsofdat
a,i
ndexespr
ovi
dean
al
ter
nat
emeansofaccessi
ng,
sor
ti
ngandsear
chi
ngdat
a.
Ani
ndexf
orournew banki
ngexampl
emi
ghti
ncl
udet
heaccountnumber
sinasor
tedor
der
.Indexes
al
l
owt
hedat
abaset
oaccessar
ecor
dwi
thouthav
ingt
osear
cht
hrought
heent
ir
etabl
e.Updat
ingdat
a
r
equi
resanext
rast
ep:
Thei
ndexmustal
sobeupdat
ed.Exampl
e:I
ndexi
nabookconsi
stsoft
wot
hings:
1)AKey
wor
dst
oredi
nor
der
2)Apoi
ntert
other
estoft
hei
nfor
mat
ion.I
nthecaseoft
hebook,
thepoi
nteri
sapagenumber
.
Appl
icat
ionsMet
adat
a
Many DBMS hav
e st
orage f
aci
l
iti
es f
or f
orms,r
epor
ts,quer
ies and ot
her appl
i
cat
ion
component
s.Appl
i
cat
ionsMet
adat
aisaccessedv
iat
hedat
abasedev
elopmentpr
ogr
ams.
Exampl
e:Lookatt
heDocument
ert
ooli
nMSAccess.I
tcanal
soshow met
adat
aforQuer
ies,
For
ms,
Repor
ts,
etc.
DATABASEDEVELOPMENT
Produci
ngadat abasemodeli
sani mpor
tantpar tofthepr ocessofdatabasedevel
opment
.
Databasedevel
opmentisgeneral
l
yapr ocessofmodel l
ing.I ti
sapr ocessofsuccessi
ve
ref
inementt
hroughthr
eel
evel
softhemodel:conceptual
,l
ogicalandphy
sicalmodel
s.
14
Okor
onkwoM.C.Cos124
Concept
ualmodel
isar
epr
esent
ati
onoft
her
eal
wor
ldexpr
essedi
nter
msofdat
arequi
rement
s.
Logicalmodel
isar
epr
esent
ati
onoft
her
eal
wor
ldexpr
essedi
nter
msoft
hepr
inci
plesofsome
datamodel.
Physi
calmodel
isar
epresentat
ionofther
ealworl
dexpressedinter
msoft
heconst
ruct
sof
someDBMSsuchastables,andaccessst
ruct
uressuchasindexes.
Somepeopleseeconcept
ualmodell
ingasastageheadedbyar equi
rementsel
i
cit
ati
on.Thi
spr
ocess
i
nvol
vesel
i
citi
ngthei
nit
ial
setofdat
aandprocessi
ngrequi
rement
sfrom user
s.
Fi
gur
e1.
4:Dat
abasedev
elopmentcy
cle
Theconcept
ualmodel
li
ngst
agecanbet
houghtofascompr
isi
ngt
wosub-
stages:
Vi
ew model
l
ingt
hisst
agewhi
cht
ransf
ormst
heuserr
equi
rement
sint
oanumberofi
ndi
vi
dualuser
v
iews,
andv
iewi
ntegr
ati
onwhi
chcombi
nest
heseschemasi
ntoasi
ngl
egl
obal
schema.
Mostconcept
ual
model
sar
ebui
l
tusi
ngconst
ruct
sfr
om t
hesemant
icdat
amodel
s.
Thel
ogi
calmodel
l
ingi
sconcer
nedwi
thdet
ermi
ningt
hecont
ent
sofadat
abasei
ndependent
lyoft
he
r
equi
rement
sofanypar
ti
cul
arphy
sicali
mpl
ement
ati
on.Thi
sisachi
evedbyt
aki
ngt
heconcept
ualmodel
asi
nput
,andt
ransf
ormi
ngi
tint
othear
chi
tect
uralmodelsuppor
ti
ngoft
het
argetdat
abasemanagement
sy
stem (
DBMS)
;suchast
her
elat
ional
dat
amodel
.
Phy
sicalmodel
l
ingi
nvol
vest
het
ransf
ormat
ionoft
hel
ogi
calmodeli
ntoadef
ini
ti
onoft
hephy
sical
modelsui
tabl
eforaspeci
fi
csof
twar
e/har
dwar
econf
igur
ati
on.Thi
sisusual
l
ysomeschemaexpr
essed
i
nthedat
adef
ini
ti
onl
anguageofSQL
DATAANALYSI
S
Thet
erm dat
aanal
ysi
sisf
requent
lyusedi
nthecont
extofdat
abasewor
k.Dat
aanal
ysi
sisat
erm
15
Okor
onkwoM.C.Cos124
gener
all
yreser
vedf
orconcept
ualandl
ogi
calmodel
l
ing.Ther
ear
etwocompl
ement
aryappr
oachest
o
conduct
ingdat
aanal
ysi
s:nor
mal
i
zat
ionandent
it
y–r
elat
ionshi
pmodel
l
ing.Nor
mal
isat
ioni
sat
echni
que
basedupont
hewor
kofCodd(
Codd,1970)
.Somet
imesr
efer
redt
oasabot
tom-
updat
abasedesi
gn
t
echni
que,nor
mal
i
sat
ioni
nvol
vest
het
ransf
ormat
ionofdat
asubj
ectt
oar
angeofdat
a-mai
ntenance
pr
obl
emsi
ntoaf
ormf
reef
rom suchpr
obl
ems.
Ent
it
y–r
elat
ionshi
p model
l
ing i
s somet
imes known as a t
op-
down desi
gn t
echni
que.ER
model
l
ingi
nvol
vesr
epr
esent
ingsomeuni
ver
seofdi
scour
sei
nter
msofent
it
iesandr
elat
ionshi
ps.
CREATI
NGADATABASE
Thef
ir
stst
epi
ncr
eat
ingadat
abasei
scr
eat
ingapl
ant
hatser
vesbot
hasagui
det
obeusedwhen
i
mpl
ement
ing t
he dat
abase and as a f
unct
ionalspeci
fi
cat
ion f
ort
he dat
abase af
teri
thas been
i
mpl
ement
ed.Thecompl
exi
tyanddet
ailofadat
abasedesi
gni
sdi
ctat
edbyt
hecompl
exi
tyandsi
zeof
t
hedat
abaseappl
i
cat
ionaswel
last
heuserpopul
ati
on.
Thenat
ureandcompl
exi
tyofadat
abaseappl
i
cat
ion,aswel
last
hepr
ocessofpl
anni
ngi
t,canv
ary
gr
eat
ly.Adat
abasecanber
elat
ivel
ysi
mpl
eanddesi
gnedf
orusebyasi
ngl
eper
son,ori
tcanbel
arge
and compl
exand desi
gned,f
orexampl
e,t
o handl
e al
lthe banki
ng t
ransact
ions f
orhundr
edsof
t
housandsofcl
i
ent
s.I
nthef
ir
stcase,
thedat
abasedesi
gnmaybel
i
ttl
emor
ethanaf
ewnot
esonsome
scr
atchpaper
.Int
hel
att
ercase,t
hedesi
gnmaybeaf
ormaldocumentwi
thhundr
edsofpagest
hat
cont
ainev
erypossi
bledet
ail
aboutt
hedat
abase.
I
npl
anni
ngt
hedat
abase,
regar
dlessofi
tssi
zeandcompl
exi
ty,
thef
oll
owi
ngar
ethebasi
cst
eps:
Gat
heri
nfor
mat
ion.
I
dent
if
ytheobj
ect
s.
Modelt
heobj
ect
s.
I
dent
if
ythet
ypesofi
nfor
mat
ionf
oreachobj
ect
.
I
dent
if
yther
elat
ionshi
psbet
weenobj
ect
s.
Gat
her
ingI
nfor
mat
ion
Bef
orecr
eat
ingadat
abase,y
oumusthav
eagoodunder
standi
ngoft
hej
obt
hedat
abasei
s
expect
ed t
o per
for
m.I
fthedat
abasei
stor
epl
aceapaper
-based ormanual
l
yper
for
med
i
nfor
mat
ionsy
stem,t
heexi
sti
ngsy
stem wi
l
lgi
vey
oumostoft
hei
nfor
mat
iony
ouneed.I
tis
i
mpor
tantt
oint
erv
iewev
ery
onei
nvol
vedi
nthesy
stem t
ofi
ndoutwhatt
heydoandwhatt
hey
needf
rom t
hedat
abase.I
tisal
soi
mpor
tantt
oident
if
ywhatt
heywantt
henewsy
stem t
odo,
as
wel
last
oident
if
ythepr
obl
ems,l
i
mit
ati
ons,andbot
tl
enecksofanyexi
sti
ngsy
stem.Col
l
ect
16
Okor
onkwoM.C.Cos124
copi
esofcust
omerst
atement
s,i
nvent
oryl
i
sts,
managementr
epor
ts,
andanyot
herdocument
s
t
hatar
epar
toft
heexi
sti
ngsy
stem,becauset
hesewi
l
lbeusef
ult
oyoui
ndesi
gni
ngt
he
dat
abaseandt
hei
nter
faces.
I
dent
if
yingt
heObj
ect
s
Dur
ingt
hepr
ocessofgat
her
ingi
nfor
mat
ion,y
oumusti
dent
if
ythekeyobj
ect
sorent
it
iest
hatwi
l
lbe
managedbyt
hedat
abase.Theobj
ectcanbeat
angi
blet
hing,
suchasaper
sonorapr
oduct
,ori
tcanbe
amor
eint
angi
blei
tem,suchasabusi
nesst
ransact
ion,adepar
tmenti
nacompany
,orapay
rol
lper
iod.
Ther
ear
eusual
l
yaf
ew pr
imar
yobj
ect
s,andaf
tert
hesear
eident
if
ied,t
her
elat
edi
temsbecome
appar
ent
.Eachdi
sti
ncti
tem i
nyourdat
abaseshoul
dhav
eacor
respondi
ngt
abl
e.
Forexampl
e,t
hepr
imar
yobj
ecti
nthepubl
i
cat
ionsdat
abasei
ncl
udesabook.Theobj
ect
srel
atedt
o
bookswi
thi
nthi
scompany
'sbusi
nessar
etheaut
hor
swhowr
otet
hebooks,
thepubl
i
sher
soft
hebooks,
hest
t oreswhi
chsel
lthem, hesal
andt est
ransact
ionsper
for
medwi
tht
hest
ores.Eachoft
heseobj
ect
s
i
sat
abl
eint
hedat
abase.
Model
li
ngt
heObj
ect
s
Ast
heobj
ect
sint
hesy
stem ar
eident
if
ied,i
tisi
mpor
tantt
orecor
dthem i
nawayt
hatr
epr
esent
sthe
sy
stem v
isual
l
y.Youcanusey
ourdat
abasemodel
asar
efer
encedur
ingi
mpl
ement
ati
onoft
hedat
abase.
Fort
hispur
pose,dat
abasedev
eloper
suset
ool
sthatr
angei
ntechni
calcompl
exi
tyf
rom penci
l
sand
scr
atchpapert
owor
dpr
ocessi
ngorspr
eadsheetpr
ogr
ams,
andev
ent
osof
twar
epr
ogr
amsspeci
fi
cal
l
y
dedi
cat
edt
othej
obofdat
amodel
l
ingf
ordat
abasedesi
gns.What
evert
ooly
oudeci
det
ouse,i
tis
i
mpor
tantt
haty
oukeepi
tup-
to-
dat
e.
I
dent
if
yingt
heTy
pesofI
nfor
mat
ionf
orEachObj
ect
Af
tert
hepr
imar
yobj
ect
sint
hedat
abasehav
ebeeni
dent
if
iedascandi
dat
esf
ort
abl
es,t
henextst
epi
s
t
oident
if
ythet
ypesofi
nfor
mat
iont
hatmustbest
oredf
oreachobj
ect
.Thesear
ethecol
umnsi
nthe
obj
ect
'st
abl
e.Thecol
umnsi
nadat
abaset
abl
econt
ainaf
ewcommont
ypesofi
nfor
mat
ion:
Rawdat
acol
umns-Thesecol
umnsst
oret
angi
blepi
ecesofi
nfor
mat
ion,
suchasnames,
det
ermi
nedby
asour
ceex
ter
nal
tot
hedat
abase.
Cat
egor
icalcol
umns-Thesecol
umnscl
assi
fyorgr
oupt
hedat
aandst
oreal
i
mit
edsel
ect
ionofdat
a
suchast
rue/
fal
se,
mar
ri
ed/
singl
e,VP/
Dir
ect
or/
GroupManager
,andsoon.
I
dent
if
iercol
umns -Thesecol
umnspr
ovi
deamechani
sm t
oident
if
yeachi
tem st
oredi
nthet
abl
e.
Thesecol
umnsof
tenhav
eidornumberi
nthei
rnames(
forexampl
e,empl
oyee_
id,i
nvoi
ce_
number
,and
publ
i
sher
_i .Thei
d) dent
if
iercol
umni
sthepr
imar
ycomponentusedbybot
huser
sandi
nter
naldat
abase
pr
ocessi
ngf
orgai
ningaccesst
oar
owofdat
aint
het
abl
e.Somet
imest
heobj
ecthasat
angi
blef
orm of
I
Dusedi
nthet
abl
e(f
orex
ampl
e,asoci
alsecur
it
ynumber
),buti
nmostsi
tuat
ionsy
oucandef
inet
he
17
Okor
onkwoM.C.Cos124
t
abl
esot
hatar
eli
abl
e,ar
ti
fi
cial
IDcanbecr
eat
edf
oreachr
ow.
Rel
ati
onal
orr
efer
ent
ial
col
umns
Thesecol
umnsest
abl
i
shal
i
nkbet
weeni
nfor
mat
ioni
nonet
abl
eandr
elat
edi
nfor
mat
ioni
nanot
hert
abl
e.
Forexampl
e,at
abl
ethatt
rackssal
est
ransact
ionswi
l
lcommonl
yhav
eal
i
nkt
othecust
omer
stabl
eso
t
hatt
hecompl
etecust
omeri
nfor
mat
ioncanbeassoci
atedwi
tht
hesal
est
ransact
ion.
Oneoft
hest
rengt
hsofadat
abasei
stheabi
l
ityt
orel
ateorassoci
atei
nfor
mat
ionaboutv
ari
ousi
temsi
n
t
hedat
abase.I
sol
atedt
ypesofi
nfor
mat
ioncanbest
oredsepar
atel
y,butt
hedat
abaseengi
necan
combi
nedat
awhennecessar
y.I
dent
if
yingt
her
elat
ionshi
psbet
weenobj
ect
sint
hedesi
gnpr
ocess
r
equi
resl
ooki
ngatt
het
abl
es,det
ermi
ninghowt
heyar
elogi
cal
l
yrel
ated,andaddi
ngr
elat
ionalcol
umns
t
hatest
abl
i
shal
i
nkf
rom onet
abl
etoanot
her
.
Dat
abaseDesi
gnConsi
der
ati
ons
Desi
gni
ngadat
abaser
equi
resanunder
standi
ngofbot
hthebusi
nessf
unct
ionsy
ouwantt
o
model
andt
hedat
abaseconcept
sandf
eat
uresusedt
orepr
esentt
hosebusi
nessf
unct
ions.
I
tisi
mpor
tantt
oaccur
atel
ydesi
gnadat
abaset
omodelt
hebusi
nessbecausei
tcanbet
ime
consumi
ngt
ochanget
hedesi
gnofadat
abasesi
gni
fi
cant
lyoncei
mpl
ement
ed.Awel
l
-desi
gned
dat
abaseal
soper
for
msbet
ter
.
Whendesi
gni
ngadat
abase,
consi
der
:
Thepur
poseoft
hedat
abaseandhowi
taf
fect
sthedesi
gn.Youhav
etocr
eat
eadat
abasepl
ant
ofi
t
y
ourpur
pose.
Dat
abasenor
mal
i
zat
ionr
ulest
hatpr
eventmi
stakesi
nthedat
abasedesi
gn.
Pr
otect
ionofy
ourdat
aint
egr
it
y.
Secur
it
yrequi
rement
soft
hedat
abaseanduserper
missi
ons.
Per
for
manceneedsoft
heappl
i
cat
ion.Youmustensur
ethatt
hedat
abasedesi
gnt
akesadv
ant
ageof
f
eat
urest
hati
mpr
oveper
for
mance.Achi
evi
ngabal
ancebet
weent
hesi
zeoft
hedat
abaseandt
he
har
dwar
econf
igur
ati
oni
sal
soi
mpor
tantf
orper
for
mance.
Mai
ntenance.
Est
imat
ingt
hesi
zeofadat
abase.
Achi
evi
ngaWel
l-
Desi
gnedDat
abase
I
nrel
ati
onal
-dat
abasedesi
gnt
heor
y,nor
mal
i
zat
ionr
ulesi
dent
if
ycer
tai
nat
tri
but
est
hatmustbepr
esent
orabsenti
nawel
l
-desi
gneddat
abase.Acompl
etedi
scussi
onofnor
mal
i
zat
ionr
ulesgoeswel
lbey
ond
t
hescopeoft
hismat
eri
al.Howev
er,t
her
ear
eaf
ewr
ulest
hatcanhel
pyouachi
eveasounddat
abase
desi
gn:
At
abl
eshoul
dhav
eani
dent
if
ier
.
18
Okor
onkwoM.C.Cos124
Thef
undament
alr
uleofdat
abasedesi
gnt
heor
yist
hateacht
abl
eshoul
dhav
eauni
quer
ow
i
dent
if
ier
,acol
umnorsetofcol
umnsusedt
odi
sti
ngui
shanysi
ngl
erecor
dfr
om ev
eryot
her
r
ecor
dint
het
abl
e.Eacht
abl
eshoul
dhav
eanI
Dcol
umn,andnot
wor
ecor
dscanshar
ethe
sameI
Dval
ue.Thecol
umnorcol
umnsser
vingast
heuni
quer
owi
dent
if
ierf
orat
abl
eist
he
pr
imar
ykeyoft
het
abl
e.
At
abl
eshoul
dst
oreonl
ydat
aforasi
ngl
ety
peofent
it
y.
At
tempt
ingt
ost
oret
oomuchi
nfor
mat
ioni
nat
abl
ecanpr
eventt
heef
fi
cientandr
eli
abl
e
managementoft
hedat
aint
het
abl
e.
At
abl
eshoul
dav
oidnul
l
abl
ecol
umns-t
abl
escanhav
ecol
umnsdef
inedt
oal
l
ownul
lval
ues.Anul
l
v
aluei
ndi
cat
est
hatt
her
eisnov
alue.Al
thoughi
tcanbeusef
ult
oal
l
ownul
lval
uesi
nisol
atedcases,
i
tisbestt
ouset
hem spar
ingl
ybecauset
heyr
equi
respeci
alhandl
i
ngt
hati
ncr
easest
hecompl
exi
ty
ofdat
aoper
ati
ons.
At
abl
eshoul
dnothav
erepeat
ingv
aluesorcol
umns.
Thet
abl
eforani
tem i
nthedat
abaseshoul
dnotcont
ainal
i
stofv
aluesf
oraspeci
fi
cpi
ece
ofi
nfor
mat
ion.Forexampl
e,abooki
nthepubsdat
abasemi
ghtbeco-
aut
hor
ed.I
fther
eisa
col
umni
nthet
it
lest
abl
efort
henameoft
heaut
hor
,thi
spr
esent
sapr
obl
em.Onesol
uti
oni
s
t
ost
oret
henameofbot
haut
hor
sint
hecol
umn,butt
hismakesi
tdi
ff
icul
ttoshowal
i
stof
t
hei
ndi
vi
dualaut
hor
s.Anot
hersol
uti
onmaybet
ochanget
hest
ruct
ureoft
het
abl
etoadd
anot
hercol
umnf
ort
henameoft
hesecondaut
hor
,butt
hisaccommodat
esonl
ytwoaut
hor
s.
Yetanot
hercol
umnmustbeaddedi
fabookhast
hreeaut
hor
s.
Tabl
es
Themosti
mpor
tantobj
ect(
component
)ofaDbi
sthet
abl
e.Adat
abaseconsi
stsofoneormor
e
t
abl
es.At
abl
eisacol
l
ect
ionofdat
a,ar
rangedi
nrowsandcol
umns.Forexampl
e,y
oumi
ghthav
eat
abl
e
f
oraut
hori
nfor
mat
ioncal
l
edaut
hor
s.Eachcol
umnwoul
dcont
ainacer
tai
nty
peofi
nfor
mat
ion,
suchas
t
heaut
hor
'sl
astname.Eachr
owwoul
dcont
ainal
lthei
nfor
mat
ionaboutaspeci
fi
caut
hor
:fi
rstname,
l
astname,
addr
ess,
andsoon.
I
nadat
abase,
youmi
ghthav
eanumberoft
abl
es,
eachdev
otedt
oaspeci
fi
ctopi
c.Forexampl
e,
t
hepubsdat
abasemi
ghtcont
aint
abl
esf
oraut
hor
s,t
it
les,andsoon.Usi
ngasepar
atet
abl
eforeach
t
opi
ccanel
i
minat
edupl
i
cat
edat
a,makedat
ast
oragemor
eef
fi
cient
,andr
educedat
a-ent
ryer
ror
s.
Tabl
esar
ethebasi
cbui
l
dingbl
ocksofdat
abasedi
agr
ams.I
nadat
abasedi
agr
am,
eacht
abl
eisl
aidout
i
namat
ri
xsot
haty
oucanseeal
lthepr
oper
ti
esdef
inedf
orev
erycol
umni
nyourdat
abaset
abl
e.
Desi
gni
ngTabl
es
Todet
ermi
net
hest
ruct
ureofanewt
abl
e,y
ouneedt
odeci
de:
19
Okor
onkwoM.C.Cos124
Whatt
ypeofdat
athet
abl
ewi
l
lcont
ain.
Whatcol
umnsy
ouneedi
nthet
abl
eandt
hedat
aty
pe(
andl
engt
h,i
frequi
red)f
oreachcol
umn.
Whi
chcol
umnsshoul
dacceptnul
lval
ues.
Whet
hert
ouseconst
rai
ntsandi
fso,
wher
e.
Whatt
ypesofi
ndexesy
ouneed,wher
eyouneedt
hem,andwhi
chcol
umnsshoul
dbet
hepr
imar
y
keyandf
orei
gnkey
.
Af
tery
oudeci
deont
hest
ruct
ureofy
ourt
abl
e,y
oucancr
eat
ethet
abl
eanddef
inei
tscol
umnsi
n
y
ourdat
abasedi
agr
am orwi
tht
heTabl
eDesi
gner
.Youcanal
soal
tert
het
abl
e'
sappear
ancei
nyour
di
agr
am sot
hatt
hei
nfor
mat
iony
ouneedi
svi
si
blewheny
ouneedi
t.Wheny
ousav
eyourt
abl
eort
he
di
agr
am,
thet
abl
eiscr
eat
edi
nyourdat
abase.
I
fyouknowexact
lywhaty
ouwanti
nat
abl
e,i
tisof
tenmostef
fi
cientt
odef
ineev
ery
thi
ngy
ouneed
att
hebegi
nni
ng,i
ncl
udi
ngt
het
abl
e'
sdat
arest
ri
cti
onsandaddi
ti
onalpr
oper
ti
es.Howev
er,i
nmany
cases,
youwi
l
ldobestt
ofi
rstcr
eat
eabasi
ctabl
eandsav
eitsoi
tiscr
eat
edi
nyourdat
abase.Youcan
t
henaddsomet
estdat
atot
het
abl
eandexper
imentwi
tht
het
abl
eint
hedat
abasedi
agr
am t
ofi
ne-
tune
i
tsdesi
gn.
TheDat
abaseDesi
gnerl
etsy
out
ryoutdi
ff
erentdesi
gnsbywor
kingwi
tht
abl
esi
nyourdi
agr
am.
Thr
oughexper
iment
ati
on,y
oucandet
ermi
newhatt
ypesofdat
aar
efr
equent
lyent
eredandquer
iedand
t
henr
edesi
gny
ourt
abl
eaccor
dingl
y.
Wheny
ouchangeat
abl
e'
sdesi
gni
nadat
abasedi
agr
am ori
nTabl
eDesi
gner
,anydat
athati
s
st
oredi
nthet
abl
eispr
eser
vedt
otheext
entpossi
ble.Wheny
ouar
esat
isf
iedwi
thy
ourbasi
cdesi
gn,
you
canaddconst
rai
nts,
indexes,
andanyaddi
ti
onal
col
umnst
haty
our
equi
re.
TheEnt
it
y-Rel
ati
onshi
pModel
TheEnt
it
y-Rel
ati
onshi
p(ER)modeli
saconcept
ualdat
amodelt
hatv
iewst
her
ealwor
ldas
ent
it
iesandr
elat
ionshi
ps.Abasi
ccomponentoft
hemodeli
stheEnt
it
y-Rel
ati
onshi
pdi
agr
am
whi
chi
susedt
ovi
sual
l
yrepr
esentdat
aobj
ect
s.Today
,ER modeli
scommonl
yusedf
or
dat
abasedesi
gn.Fort
hedat
abasedesi
gner
,theut
il
it
yoft
heERmodel
is:
a. I
tmapswel
ltot
her
elat
ional
model
.Theconst
ruct
susedi
ntheERmodel
caneasi
l
ybe
t
ransf
ormedi
ntor
elat
ional
tabl
es.
b. I
tissi
mpl
eandeasyt
ounder
standwi
thami
nimum oft
rai
ning.Ther
efor
e,t
hemodel
can
beusedbyt
hedat
abasedesi
gnert
ocommuni
cat
ethedesi
gnt
otheenduser
.
c. I
naddi
ti
on,
themodel
canbeusedasadesi
gnpl
anbyt
hedat
abasedev
elopert
o
i
mpl
ementadat
amodel
inspeci
fi
cdat
abasemanagementsof
twar
e.
20
Okor
onkwoM.C.Cos124
OSFi
leSystem St orageBasedAppr oach
•Fi
lesofr ecords–usedf ordat astor age
•datar edundancy–wast ageofspace
•mai ntainingconsi st
encybecomesdi ffi
cult
•Recordst ructures–har dcodedi ntot hepr ograms
•structuremodi fi
cati
ons–har dt operform
•Eachdif f
erentdat aaccessr equest( aquery)
•performedbyasepar atepr ogr am
•diffi
cultt oantici
pateal lsuchr equest s
•Creati
ngt hesy stem
•requiresal otofeffor
t
•Managi ngconcur rentaccessandf ail
ur er
ecov eryar
edi
ff
icul
t
I
ntheearlyday s,databaseappl icat
ionswer ebuil
tontopoffilesyst
ems
Thedr
awbacksofusi ngfil
esy stemst ost oredataare:
1_Dat aredundancyandi nconsi stency
✔ Mul tipl
ef i
l
ef ormats,dupl icat
ionofinfor
mationindif
fer
entfi
les
2Diffi
cul t
yinaccessi ngdat a
✔ Needt owr i
teanewpr ogram tocarryouteachnewt ask
3Dat aisolati
on—mul t
iplefi
lesandf ormats
4Integri
t yproblems
✔I nt
egr i
tyconstraint
s( e.g.accountbalance>0)becomepar tofprogr
am code
✔ Har dt oaddnewconst raintsorchangeexist
ingones
5Atomici
tyofupdat es
✔ Failur
esmayl eavedatabasei nani nconsist
entstat
ewithpartial
updates
carri
edout
✔ E.g.tr
ansf eroffundsf r
om oneaccountt oanothershouldeit
hercompleteor
nothappenatal l
6Concurrentaccessbymul t
ipleusers
✔ Concur r
entaccessedneededf orperformance
✔ Uncont r
olledconcurrentaccessescanl eadtoinconsi
stenci
es
–E. g.twopeopler eadingabal anceandupdat i
ngitatthesamet i
me
7Securi
typroblems
_Dat
abasesystemsof fersoluti
onst oalltheabov eproblems
DBMSAppr oach
DBMS
•separationofdat aandmet adata
•fl
exibil
i
tyofchangi ngmet adata
•program- dat aindependence
Dataaccesslanguage
•standardi zed–SQL
•ad-hocquer yformul ati
on–easy
Syst
em dev el
opment
•l
essef for trequir
ed
•concentr ationonl ogicall
eveldesignisenough
•component stoorgani zedatastorageprocessquer
ies,
manageconcur
rentaccess,
21
Okor
onkwoM.C.Cos124
r
ecov
eryf
rom f
ail
ures,
manageaccesscont
rol
areal
lav
ail
abl
e
Lev
elsofAbst
ract
ion
_Physical l
eveldescr i
beshowar ecord(e.
g.,cust
omer )i
sstored.
_Logical l
evel:
descr ibesdatastoredindatabase,andtherel
ationshi
psamongt
hedat
a.
typecust omer=r ecord
name:st ri
ng;
str
eet:stri
ng;
cit
y:int
eger;
end;
_Viewl evel
:applicationprogramshi dedetai
lsofdatatypes.
Viewscanal sohideinformati
on( e.
g.,sal
ary)f
orsecuri
typurposes.
Vi
ewofDat
a
Thi
spr
esent
sthear
chi
tect
uref
oradat
abasesy
stem
I
nst
ancesandSchemas
Si
milart
otypesandv ariabl
esi nprogrammi nglanguages,Schemai sthel
ogi
cal
str
uctur
eoft
he
dat
abase
o Forexampl e,thedat abaseconsistsofinformati
onaboutasetofcustomersand
accountsandt herelati
onshipbetweent hem)
o Anal ogoust oty peinformati
onofav ar
iablei
napr ogram
o Phy sicalschema–i sthedatabasedesi gnatthephysicall
evel
o Logi calschema–i st hedatabasedesignatthelogicallev
el
I
nstance–i stheact ualcontentofthedatabaseatapar t
icul
arpointi
nti
me
o Anal ogoustothev alueofavariable
Phy
sicalDat aIndependence–t heabili
tyt
omodi f
ythephysical
schemawithoutchangi
ngt
he
l
ogi
cal schema
o Appl i
cationsdependont helogi
calschema
o Ingener al,t
heinter
facesbet weenthev ar
iousl
evelsandcomponentsshouldbewel
l
def
inedsot hatchangesi nsomepar tsdonotseriouslyi
nfl
uenceot
hers.
22
Okor
onkwoM.C.Cos124
Dat
aModel
s(DM)
DM isthecollect
ionofconceptual t
ool
st hatdescri
bet hedatabaseatacer
tai
nlev
elof
abst
racti
on.
o Concept ualDat aModel
Iti
sahi ghl
eveldescr
ipti
on
Us efulf
orr
equirementsunderstanding.
o RepresentationalDataModel
De scri
best helogi
calr
epresentati
onofdat awithoutgivi
ngdet
ail
sofphysi
cal
representation.
oPhysicalDataModel
Pr
ovi
dest
hedescr
ipt
iongi
vi
ngdet
ail
saboutr
ecor
dfor
mat
s,f
il
est
ruct
ureset
c .
DM theref
or e,isacol l
ectionoft ool
sfordescri
bing:data,datarel
ati
onshi
ps,
dat
asemant
ics,
dat
aconst raints,it
si mplement edusinganyorcombi nati
onof :
_Entity-
Relationshipmodel
_Relational model
_Othermodel s:
_obj ect-ori
entedmodel
_semi -
structureddatamodels
_Ol dermodel s:networ
kmodel andhierarchicalmodel
Ent
it
y-Rel
ati
onshi
pModel
Thi
sisaconcept
ual
lev
eldat
amodel
.Itpr
ovi
dest sofent
heconcept it
ies,
rel
ati
onshi
psand
att
ri
but
es.
Exampl
eofschemai
ntheent
it
y-r
elat
ionshi
pmodel
E-
Rmodelofr ealwor l
d
_Enti
ti
es( objects)
✔ E. g.customer s,accounts,bankbranch
_Rel
ationshipsbet weenent it
ies
✔ E. g.AccountA- 101i sheldbycustomerJohnson
✔ Rel ati psetdeposi
onshi torassoci
atescustomer
swithaccounts
_Widelyusedf ordatabasedesign
_Databasedesi gninE-Rmodel usual
lyconver
tedtodesi
gnintherel
ati
onal
model
,whi
chi
s
usedf orst or
ageandpr ocessing
ForExampl
e:
TheUniver
sit
yDatabaseContext
Enti
ti
es:st
udentf
,acul
tymember
,cour
se,
depar
tment
set
c.
23
Okor
onkwoM.C.Cos124
Rel
ati
onships:enrolmentrel
ati
onshipbetweenstudent&course,
empl oymentrel
ati
onshipbetweenfacul
tymember ,
depar
tmentet
c.
Att
ri
butes:name,rollNumber,addr
essetc.ofst
, udent
enti
tyname,
, empNo,
phoneNo, et
c.,offacul
tyenti
tyetc.
Repr
esent
ati
onalLev
elDat
aModel
Rel
ati
onalModel
Rel
ati
onal
Model
:Pr
ovi
dest
heconceptofar
elat
ion.
I
nthecont
extofuni
ver
sit
ydat
abase:
Exampl
eoft
abul
ardat
aint
her
elat
ional
model
At
tr
ibut
es
24
Okor
onkwoM.C.Cos124
Dat
aver
susSchemaorMet
a
o Data:
InDBMSi sgener i
cinnat ure
Isnotti
edt oasi ngledat abase
capableofmanagi ngbysev er
al dat
abasesatati
me
o Dataandschemaar estoredsepar atel
y.
o I
nRDBMScont ext:
Schemai ncludes–t ablenames, att
ri
butenames,dat
aty
pesandconst
rai
ntset
c.
o Databasedefiniti
on–set tingupt heskelet
onstruct
ure
o DatabaseLoadi ng/populating–st ori
ngdata
Thet
hreel
evel
sANSISPARCDat
abaseSy
stem (
lev
elofDat
aabst
ract
ion)
TheANSISPARCar chi
tectureisdi
vi
dedi
ntot
hreel
evel
s:
1)Ext
ernallevel
2)Conceptual l
evel
3)I
nternall
ev el
Fi
gur
e:Thr
eel
evel
sANSISPARCDat
abaseSy
stem
ViewLevelSchema
Eachvi
ewdescr i
besanaspectoft hedatabaserelevantt
oapar
ti
cul
argr
oupofuser
s.
Forinst
ance,inthecontextofali
brar
ydat abase:
o BooksPur chaseSecti
on
o Issue/
Ret urnsManagementSect i
on
o UsersManagementSect i
on
Eachsecti
onviews/usesapor ti
onoftheentir
edat a.
Viewscanbesetupf oreachsect i
onofusers.
Logi
calLevelSchema
o Descri
besthel
ogi
cal
str
uct
ureoft
heent
ir
edat
abase.
25
Okor
onkwoM.C.Cos124
o Nophy
sical
lev
eldet
ail
sar
egi
ven.
Phy
sicalLevelSchema
o Descr i
best hephy
sical
str
uct
ureofdat
aint
ermsofr
ecor
dfor
mat
s,f
il
est
ruct
ures,
i
ndexeset c.
Remarks
•Viewsareopti
onal
-Canbesetupi ft
heDBsy stem i
sver
ylar
geandi
feasi
l
yident
if
iabl
euser
-gr
oupsex
ist
•Thelogi
calschemeisessenti
al
•ModernRDBMS’ shi
dedetail
softhephysi
call
ayer
Ext
ernalLevel(ViewLevel-VL)
o Thi sisthehighestlevelofdataabst racti
on.
o I tdescri
besonl ypartoftheentiredat abaset hatapar t
icul
arenduserrequi
res.
o Ext ernalvi
ewi sdescribesbyext ernal schema.
o Ext ernalschemaconsi stsofdefini t
ionofl ogicalrecords,r
elat
ionshi
pintheext
ernal
view
andmet hodofder ivi
ngt heobject sfrom theconcept ualvi
ew.
o Thi sobjectincl
udesent iti
es,
attributesandr elat
ionship.
ConceptualLevel(Logi
calLevel-LL)
o Thi si
sthenexthigherlevel
ofthedataabstr
acti
on.
o I tdescri
beswhatdat aarestor
edinthedatabaseandwhatr el
ati
onshi
psexi
stamong
thosedat a.
o Concept ualvi
ewisdefinedbyconceptual
schema.Itdescr
ibesallr
ecor
dsand
relati
onship.
I
nternalLevel(PhysicalLevel-PL)
o Thisi sthelowestlevelofthedataabstracti
on.
o Itdescr i
beshowt hedat aareact
uallystoredonstoragedev
ices.
o Thei nternalv
iewi sdescri
bedbyinternalschema.
o Internalschemaconsi stsofdefi
nit
ionofst or
edrecord,met
hodofrepr
esent
ingt
hedat
a
f
iel
dandaccessmet hodused.
Dat
aIndependence
Datai
ndependencyistheabi
li
tyt
omodi f
yaschemadef
ini
ti
oni
nonel
evel
wit
houtaf
fect
inga
schemadefi
nit
ioninthenexthi
gherl
evel
.
Ty
pesofdat
aindependence
Physi
caldatai
ndependence
Logicaldataindependence
Physicaldataindependence
Thisistheabili
tytomodi fyphysical
levelschemawi thoutaf f
ectingthelogi
calorvi
ewlevel
schema.Per formancet uni
ng–modi fi
cationatphysicall
evel;creati
nganewi ndexetc.
PhysicalDataIndependence–modi fi
cationislocal
ized
Thisisachievedbysui t
ablymodi f
yingPL- LLmapping; i
tisav eryimport
antfeat
ureof
moder nDBMS.
o Phy sicaldat
ai ndependenceallowschangesi nphy sicalstor
agedev i
cesororgani
zat
ion
offi
lewithoutchangei ntheconcept ualvi
eworext ernalview.
26
Okor
onkwoM.C.Cos124
o Modi ficat i
onsatt heinternal level areoccasional l
ynecessar yt oimpr oveper for
mance.
o Phy sical dataindependencesepar atesconcept ual l
ev el f
rom t heinternallevel.
o I tiseasyt oachi evephy sical dat ai ndependence.
Logicaldat aindependence
Thisistheabi l
itytochanget hel ogi cal l
ev elschemewi thoutaf f
ectingt heviewl evelschemesor
appli
cationpr ogr ams.
o Logi cal dat aindependencei st heabi l
i
tytomodi f ytheconcept ualschemawi thout
requiringanychangei nappl icat i
onpr ograms.
o Concept ual schemacanbechangedwi t
houtaff ectingt heexi sti
ngext ernalschema.
o Modi ficat i
onsatLLar enecessar ywhenev erthel ogical structureoft hedat abaseis
altered.
o Logi cal dat aindependencesepar atesexternallev elfrom theconcept ual vi
ew.
o I tisdi f
ficulttoachievel ogi cal datai ndependence.
Addinganewat tri
butet osomer el ation;
•noneedt ochanget hepr ogr amsorv i
ewst hatdon’ trequiret ouset henewat tr
ibut
e
Deleti
nganat t
ribute;
•noneedt ochanget hepr ogr amsorv i
ewst hatuset her emai ningdata
•viewdef ini
tionsinVL- LLmappi ngonl yneedt obechangedf orv iewst hatuset hedelet
ed
at t
ribute
Dat
abaseManagementSy
stem (
DBMS)
ADBMSi
sexact
lywhati
tsnamesuggest
sapi
eceofsof
twar
eformanagi
ngdat
abasesandpr
ovi
dingaccess
t
othem.Butbewar
nedi
nthei
ndust
ryt
het
erm dat
abasei
scommonl
yusedt
oref
ert
oaDBMS,
especi
all
yin
pr
omot
ionall
i
ter
atur
e.Youar
est
rongl
ydi
scour
agedf
rom adopt
ingsuchsl
oppypr
act
ice(
ifsuchasy
stem i
s
adat
abase,
whatar
ethet
hingsi
tmanages?
)
ADBMSr ocommandsgi
espondst venbyappl
i
cat
ionpr
ogr
ams,
cust
om-
wri
tt
enorgener
al-
pur
pose,
execut
ingonbehal
fofuser
s.
o Commandsar
ewr
it
teni
nthedat
abasel
anguageoft
heDBMS(
e.g.
,SQL)
.
o Responsesi
ncl
udecompl
eti
oncodes,
messagesandr
esul
tsofquer
ies.
ADat
abaseManagementSy
stem i
sanor
gani
zedsetoff
aci
l
iti
esf
oraccessi
ngandmai
ntai
ning
oneormor
edat
abases.ADBMSi
sashel
lwhi
chsur
roundsadat
abaseorser
iesofdat
abasesand
t
hroughwhi
chal
lint
eract
ionst
akepl
acewi
tht
hedat
abase.Thei
nter
act
ionscat
eredf
orbymost
exi
sti
ngDBMSf
all
int
ofourmai
ngr
oups(
seeFi
gur
ebel
ow)
:
Dat
adef
ini
ti
on–def
ini
ngnewdat
ast
ruct
uresf
oradat
abase,
remov
ingdat
ast
ruct
uresf
rom t
he
dat
abase,
modi
fyi
ngt
hest
ruct
ureofexi
sti
ngdat
a
Dat
amai
ntenance–i
nser
ti
ngnewdat
aint
oexi
sti
ngdat
ast
ruct
ures,
updat
ingdat
ainexi
sti
ngdat
a
st
ruct
ures,
del
eti
ngdat
afr
om exi
sti
ngdat
ast
ruct
ures
Dat
aret
ri
eval–quer
yingexi
sti
ngdat
abyend-
user
sandex
tract
ingdat
aforusebyappl
i
cat
ion
pr
ogr
ams
Dat
acont
rol–cr
eat
ingandmoni
tor
inguser
soft
hedat
abase,
rest
ri
cti
ngaccesst
odat
aint
he
dat
abaseandmoni
tor
ingt
heper
for
manceofdat
abases.
27
Okor
onkwoM.C.Cos124
Fi
gur
e1.
5:Funct
ionsofDBMS
Funct
ionsofDBMS
1.ToSt
oredat
aandt
hedef
ini
ti
onofdat
arel
ati
onshi
ps(
met
adat
a)
2.Cr
eat
ethecompl
exst
ruct
uresr
equi
redf
ordat
ast
orage.
3.Tr
ansf
orm dat
atoconf
ormt
othedat
ast
ruct
ure.
4.Cr
eat
easecur
it
ysy
stem andenf
orcesecur
it
yandpr
ivacyr
ules.
5.Cr
eat
est
ruct
urest
hatal
l
owmul
ti
pleuseraccesst
othedat
a.
6.Pr
ovi
debackupanddat
arecov
erypr
ocedur
etoensur
esaf
etyandi
ntegr
it
y.
7.Pr
ovi
deandenf
orcei
ntegr
it
yrul
etoel
i
minat
eint
egr
it
ypr
obl
em.
8.Pr
ovi
dedat
aaccessv
iaquer
ylanguage.
I
nresponset
orequest
sfr
om appl
i
cat
ionpr
ogr
ams,
weexpectaDBMSt
obeabl
e,f
orexampl
e,
t
o
o cr
eat
eanddest
royv
ari
abl
esi
nthedat
abase
o t
akenot
eofi
ntegr
it
yrul const
es( rai
nts)
o t eofaut
akenot hor
isat
ions(
whoi
sal
l
owedt
odowhat
,towhat
)
o updat
evar
iabl
es(
honour
ingconst
rai
ntsandaut
hor
isat
ions)
o pr
ovi
der
esul
tsofquer
ies
Toampl
i
fysomeoft
het
ermsj
ustused:
Ther
equest
staket
hef
orm ofcommandswr
it
teni
nthedat
abasel
anguagesuppor
tedbyt
heDB
I
nor
dert
osuppor
tmul
ti
pleconcur
rentuser
saDBMSnor
mal
l
yoper
atesasaser
ver
.It
s
i
mmedi
ateuser
sar
ethust
hoseappl
i
cat
ionpr
ogr
ams,
r ngascl
unni i
ent
soft
hisser
ver
,ty
pical
l
y
(
thoughnotnecessar
il
y fofenduser
)onbehal s.Thus, ndofcommuni
someki cat
ionpr
otocoli
s
neededf
ort
het
ransmi
ssi
onofcommandsandr
esponsesbet
weencl
i
entandser
ver
.Bef
ore
submi
tt
ing commands t
othe ser
vera cl
i
entappl
i
cat
ion pr
ogr
am mustf
ir
stest
abl
i
sh a
connect
iont
oit
,thusi
nit
iat
ingasessi
on,whi
cht
ypi
cal
l
ylast
sunt
ilt
hecl
i
entexpl
i
cit
ly,
asksf
or
i
ttobet
ermi
nat
ed.Thati
sal
ly oknowaboutcl
ouneedt i
ent
-ser
verar
chi
tect
ureasf
arast
his
28
Okor
onkwoM.C.Cos124
cour
sei
sconcer
ned.
Dat
abaseLanguage
Tor
epeat
,thecommandsgi
vent
oaDBMSbyanappl
i
cat
ionar
ewr
it
teni
nthedat
abase
l
anguageoft
heDBMS.Thet
erm dat
asubl
anguagei
ssomet
imesusedi
nst
eadofdat
abase
l
anguage.The“
sub”pr
efi
xref
erst
othef
actt
hatappl
i
cat
ionpr
ogr
amsar
esomet
imeswr
it
teni
n
some mor
e gener
al-
pur
pose pr
ogr
ammi
ng l
anguage (
the “
host
”language)
,in whi
ch t
he
dat
abase l
anguage commands ar
e embedded i
n some pr
escr
ibed st
yle.Somet
imes t
he
embeddi
ngst
ylei
ssucht
hatt
heembeddedst
atement
sar
eunr
ecogni
zedbyt
hehostl
anguage
compi
l
erori
nter
pret
er alpr
,andsomespeci epr
ocessori
sused t
orepl
acet
heembedded
st
atement
sby
,forexampl
e,CALLst
atement
sint
hehostl
anguage.
Aquer
yisanexpr
essi
ont
hat
,whenev
aluat
ed,y
iel
dssomer
esul
tder
ivedf
rom t
hedat
abase.
Quer
iesar
ewhatmakedat
abasesusef
ul.Not
ethataquer
yisnotofi
tsel
facommand.The
DBMSmi
ghtsuppor
tsomeki
ndofcommandt
oev
aluat
eagi
venquer
yandmaket
her
esul
t
av
ail
abl
eforaccess,al
sousi
ngDBMScommands,byt
heappl
i
cat
ionpr
ogr
am.Theappl
i
cat
ion
pr
ogr
am mi
ghtexecut
esuchcommandsi
nor
dert
odi
spl
ayaquer
yresul
t(usual
l
yint
abul
ar
f
orm)i
nawi
ndow.
Dat
abaseuser
s
Therearefourdi ff
erentdat abaseuser s.
o Applicat ionprogr ammer s-Theseuser sarecomput erprofessi
onalswhowr i
te
applicat i
onpr ogr amsusi ngsomet ools.
o Sophi sticateduser s-Theseuser sint
eractwi t
hsystem withoutwrit
ingprogram.They
formt heirrequesti nadat abasequer yl anguage.
o Speci ali
zeduser s-Theseuser swr i
tespeci al
i
zeddat abaseappli
cati
onst hatdonotfit
intothet radi
tional datapr ocessingf r
amewor k.
o Naiveuser s-Thesear eunsophi sti
cateduser swhohav ev er
ylit
tl
eknowl edgeof
databasesy stem.
o Theseuser sinteractwitht hesy stem byusingoneoft heapplicat
ionprograms
t
hathav ebeenwr ittenprev i
ously.
o Exampl es, peopleaccessi ngdat abaseov ertheweb, banktel
lers,
cleri
calstaf
fetc.
Dat
abaseSyst
em Ar
chi
tect
ure
Component
sofaDBMS
Thesefuncti
onaluni
tsofadatabasesy
stem canbedi
vi
dedi
ntot
wopar
ts:
1.Quer yPr
ocessorUni
ts(Component
s)
2.StorageManagerUnit
s
Quer
yPr
ocessorUni
ts:
Quer
ypr
ocessoruni
tsdeal
wit
hexecut
ionofdat
adef
ini
ti
onl
anguageDDLanddat
a
29
Okor
onkwoM.C.Cos124
mani
pul
ati
onl
anguageDMLst
atement
s.
DDLInterpreter—InterpretsDDLst at
ementsintoasetoft ablescontai
ningmetadat
a.
DMLCompi ler—Tr anslatesDMLst at
ement sint
ol owleveli
nstruct
ionsthatt
hequery
eval
uati
onengi neunder stands.
EmbeddedDMLPr e-compi ler—Conv er
tsDMLst atement
sembeddedi nanappli
cat
ion
pr
ogram intonor malprocedur ecaI
lsi
nt hehostlanguage.
QueryEvaluationEngine—Execut esl
owl eveli
nst r
ucti
onsgeneratedbyDMLcompi ler
.
St
orageManagerUni
ts:
Stor
agemanageruni
tspr
ovi
deinter
facebet
weenthelowl
evel
dat
ast
oredi
ndat
abaseandt
he
appl
icat
ionpr
ogr
ams&queriessubmitt
edtothesy
stem
Aut
hor
izat
ionManager—Checkst
heaut
hor
it
yofuser
stoaccessdat
a.
I
ntegr
it
yManager—Checksf
ort
hesat
isf
act
ionoft
hei
ntegr
it
yconst
rai
nts.
Tr
ansact
ionManager—Pr
eser
vesat
omi
cit
yandcont
rol
sconcur
rency
.
Fi
leManager—Managesal
l
ocat
ionofspaceondi
skst
orage.
Buf
ferManager—Fet
chesdat
abei
ngusedf
rom di
skst
oraget
omemor
y.
30
Okor
onkwoM.C.Cos124
Fi
gur
e:Dat
abaseSy
stem Ar
chi
tect
ure
Inaddi
tiontothesef uncti
onal units,sev eraldatastructuresarer equi
redtoimplementphy si
cal
stor
agesy stem.Thesear edescr ibedbel ow:
o Dat aFil
es—Tost or
euserdat a.
o Dat aDictionar yandSy stem Cat alog—Tost oremet adata.Iti
susedheav i
l
y, al
mostfor
eachandev erydatamani pulationoper ation.So,itshouldbeaccessedef fi
cient
ly.
o Indices—Topr ov
idefasteraccesst odat aitems.
o St at
isti
calDat a—Tost or est atisti
calinformationaboutt hedat ai
nthedatabase.This
informationi susedbyt hequer ypr ocessortosel ecteff
icientwaystoexecuteaquer y
.
3t
ierar
chi
tect
uredi
agr
am
Mostwidel
yusedar
chi
tect
ureis3-
ti
erar
chi
tect
ure.Thi
sar
chi
tect
uresepar
ateseacht
ierf
rom
eachot
heronbasi
sofusers.
Dat
abase(Dat
a)Tier
o Atthisti
er,
onlydat
abaseresides.
o Databasealongwit
hitsqueryprocessi
nglanguagessi
tsi
nlay
er-
3of3-
ti
erar
chi
tect
ure.
o Ital
socontainsal
lrel
ati
onsandt hei
rconstr
aint
s.
31
Okor
onkwoM.C.Cos124
Fi
gur
e:The3t
ierar
chi
tect
ure
Appli
cat
ion(Mi ddle)Ti er
o Atthi
st ierresidest heappl i
cat
ionser v erandpr ogram,whi chaccessdat abase.
o Forausert histierwor ksasabst r
actedv iewofdat abase.
o Usersar eunawar eofanyexi stenceofdat abasebeyondappl icati
on.
o Fordatabase- ti
er ,applicati
ontieristheuser .
o Databaset ierisnotawar eofanyot heruserbey ondapplicat
iont i
er.
o Thisti
erwor ksasmedi at
orbetweent het wo; UserandDat atier.
User(Pr
esentation)Ti er
o Anendusersi t
sont hi
st i
er.
o From auser saspectt histi
erisever y
t hing.
o He/shedoesn' tknowaboutanyex istenceorf orm ofdatabasebey ondt hislayer
.
o Atthi
sl ayermul ti
plev iewsofdat abasecanbepr ovi
dedbyt heappl icat
ion.
o Allvi
ewsar egener atedbyanappl i
cat ion,whi chresi
desinappl icat
iontier.
DBkey s.
Superkey-Asuperkeyisasetofoneormor eatt
ri
butesthatall
owustoident
if
yeachtuple
uniquel
yinarel
ati
on.
Forexample,t
heenrol
l_
no,r
oll
_no,depart
_nameofast udenti
ssuff
ici
entt
odisti
ngui
shone
studentt
uplefr
om anot
her
.So{enroll
_no}and{
rol
l_no,depart
_name}bot
haresuperkey.
St
epsi
nDat
abaseSy
stem Dev
elopmentPr
ocess
St
ep1.Requi
rement
scoll
ect
ion
Datamodelr
equi
rement
s
32
Okor
onkwoM.C.Cos124
o Fi ndthev ari
ouspiecesofdat atobestor
edandthei
nterr
elat
ionshi
ps.
o Thenr epr esentthem usingaconceptual
datamodelsuchasE/ Rmodel.
Funct
ionalr
equi r
ement s
o Fi ndthev ari
ousoper at
ionsthatneedtobeper
for
medaspar tofrunni
ngthe
enterprise.
o Suchas: acquiri
nganewbook, enrol
li
nganewuser,
issui
ngabookt otheuser
,
recordingt hereturnofabooket c.
St
ep2.Conv
ertthedatamodeli
ntoar epresent
ati
onal
lev
el model
o Typical
l
yrel
ati
onaldatamodel .
o ChooseanRDBMSsy stem andcreat
ethedatabase.
St
ep3.Conver
tthef
uncti
onalrequi
rement sintoappli
cat
ionpr
ograms
Devel
opmentofprogramsinahi gh-
levellanguaget
hatuseembeddedSQLt
oint
eractwi
th
thedat
abaseandcarryouttherequi
redt asks.
Rel
ati
onDecomposi
ti
onandt
ypesofdecomposi
ti
on
Decomposi
ti
on
Thi
sist
hepr
ocessofbr
eaki
ngdowngi
venr
elat
ioni
ntot
woormor
erel
ati
ons.
Her
e,ar el
ati
onRmayber eplacedbytwoormor erel
ationsinsuchawayt
hat-
1.Eachnewr elat
ioncontai
nsasubsetoftheattr
ibutesofR,and
2.Together
,theyalli
ncl
udealltupl
esandattr
ibut
esofR.
Rel
ati
onaldat
abasedesignprocessstar
tswit
hauniver
salrel
ati
onschemaR={ A1,A2,A3.
..
An),
whichincl
udesallt
heattr
ibut
esofthedat
abase.Theuniver
salr
elat
ionst
atest
hat
ever
yatt
ri
butenamei suni
que.
Usi
ngf unct
ional
dependencies,
thisuni
ver
salr
elat
ionschemai
sdecomposedi
ntoasetof
r
elati
onschemasD={ R1,R2,R3,…,
Rm}.
Now,
Dbecomest
her
elat
ional
dat
abaseschemaandDi
sref
err
edasdecomposi
ti
onofR.
General
ly
,decomposi
ti
onisusedt
oel
i
minat
ethepi
tf
all
soft
hepoordat
abasedesi
gndur
ing
normali
zat
ionpr
ocess.
Forexampl
e,consi
dert
her
elat
ionAccount
_Br
anchgi
veni
nfi
gur
ebel
ow:
Thi
srelat
ioncanbedividedwithtwodi
ff
erentr
elat
ions
1.Account(Ano,
Balance,Bname)
2.Branch(Bname,Baddress)
Theset
wor
elat
ionsar
eshowni
nbel
owf
igur
e
33
Okor
onkwoM.C.Cos124
Adecomposi
ti
onofr
elat
ioncanbeei
therl
ossydecomposi
ti
onorl
ossl
essdecomposi
ti
on.
Ther
ear
etwotypesofdecomposi
ti
on
1.l
ossydecomposi
ti
on
2.l
ossl
essdecomposit
ion(
non-
lossdecomposi
ti
on)
LossyDecomposi t
ion
Thedecomposi ti
onofrel
ati
onRi nt
oR1andR2islossywhent
hej
oinofR1andR2doesnoty
iel
dthe
samerel
ationasinR.
Thisisal
soreferr
edaslossy
-joi
ndecomposi
ti
on.
Thedisadv
antageofsuchkindofdecomposi
ti
onisthatsomeinf
ormati
onislostdur
ingret
ri
evalof
or
igi
nalrel
ati
on.Andso,
suchki
ndofdecomposi
ti
onisref
err
edaslossydecomposi
ti
on.
From pr
act
ical
poi
ntofvi
ew,decomposi
ti
onshoul
dnotbelossydecomposi
ti
on.
Example
Af i
gureshowsarelat
ionAccount
.Thisrel
ati
onisdecomposedi nt
otwor el
ati
ons:Acc_
Baland
Bal
_Br
anch.
Now,whenthesetwor el
ati
onsarejoi
nedonthecommonatt
ribut
eBalance,
theresul
tant
r
elat
ionwi
lll
ooklikeAcct_
Joined.Thi
sAcct
_Joi
nedr
elat
ioncont
ainsrowsinadditi
onto
t
hoseinori
ginal
relat
ionAccount.
Her
e,i
tisnotpossi
blet
ospeci
fyt
hati
nwhi
chbr
anchaccountA01orA02bel
ongs.
So,
inf
ormat
ionhasbeenl
ostbyt
hisdecomposi
ti
onandt
henj
oinoper
ati
on.
I
not
herwords,decomposi
ti
onislossyifdecomposeint
oR1andR2andagaincombine(j
oin)
R1andR2wecannotgetor i
ginalt
ableasR1,overX,wher
eRisanor
igi
nalr
elat
ion,
R1and
R2aredecomposedrel
ati
ons,andXi sacommonat tri
but
ebet
weent
hesetworelat
ions.
Lossl
ess(Non-l
oss)Decomposi t
ion
Thedecompositi
onofrelati
onRi nt
oR1andR2i
slossl
esswhent
hej
oinofR1andR2
producest
hesamer elat
ionasinR.
34
Okor
onkwoM.C.Cos124
Thi
sisal
sor
efer
redasanon-
addi
ti
ve(
non-
loss)decomposi
ti
on.
Alldecomposi
ti
onsmustbel
ossl
ess.
Example
Agai
n,t
hesamer
elat
ionAccounti
sdecomposedi
ntot
wor
elat
ionsAcct
_Bal
andAcct
_Br
anch.
Now,whenthesetworel
ati
onsarejoi
nedonthecommoncolumnAno,theresult
antr
elat
ion
wil
llookli
keAcc_
Joinedrel
ati
on.Thi
srel
ati
oni
sexact
lysameasthatoforigi
nalr
elat
ion
Account.
I
not
herwor
ds,
all
thei
nfor
mat
ionofor
igi
nal
rel
ati
oni
spr
eser
vedher
e.
I
nlossl
essdecomposi
ti
on,noanyfaket
upl
esar
egener
atedwhenanat
uralj
oini
sappl
i
edt
o
therel
ati
onsi
nthedecomposi
ti
on.
I
not
herwor ds,decomposi
ti
onisl
ossyi
fR=j oinofR1andR2,ov
erX,wher
eRisanor
igi
nal
r
elat
ion,R1anR2ar edecomposedr
elat
ions,andxi
sacommonat t
ri
but
ebet
weenthese
t
wor el
ati
ons.
Anomal
yinDat
abaseDesi
gn
Anomal i
esarepr obl
emst hatcanoccurinpoorlypl
anned,un-normal
izeddatabasewher eal
lthe
dataarestoredinonet abl
e.
Therearethreetypesofanomal i
esthatcanari
seinthedatabasebecauseofr edundancyar
e
o Insertanomalies
o Deleteanomal ies
o Updat e/Modi ficat
ionanomali
es
Considerarelat
ionemp_ dept( E#,Ename,Addr
ess,D#,Dname, Dmgr#)withE#asapr imar
y
key.
Inser
tanomal y
:
Letusassumet hatanewdepar tmenthasbeenstar
tedbyt heorgani
zat
ionbuti ni
ti
all
yther
eis
noempl oyeeappoi ntedfort hatdepartment
,thent het upleforthi
sdepar tmentcannotbe
i
nsertedintot histableast heE#wi l
lhaveNULLv alue,whichisnotal l
owedbecauseE#i s
primarykey
.
Thi
skindofpr oblem i
nt herel
ati
onwheresomet uplecannotbeinsertedisknownas
i
nsertanomaly.
Del
eteanomaly :
Nowconsiderthereisonl
yoneemploy
eeinsomedepar
tmentandthatempl
oyeeleav
esthe
or
ganizat
ion,
thent het
upleoft
hatemploy
eehast
obedelet
edfrom t
hetabl
e,buti
naddi
tiont
o
35
Okor
onkwoM.C.Cos124
thati
nformati
onaboutthedepar
tmentalsowi
llbedel
eted.
Thi
skindofpr
oblem i
ntherel
ati
onwheredelet
ionofsometupl
escanl
eadt
olossof
someot herdat
anotint
endedtoberemov edi
sknownasdel et
eanomal
y.
Updat e/Modi fi
cat
ionanomal y
:
Supposet hemanagerofadepar tmenthaschanged,thisrequiresthattheDmgr #inallt
he
tupl
escor respondi
ngtothatdepart
mentmustbechangedt or efl
ectthenewst atus.
I
fwef ai
ltoupdateallt
hetuplesofgiv
endepart
ment ,
t hentwodi ffer
entrecordsofempl oy
ee
workingint hesamedepartmentmightshowdiff
erentDmgr #whi chleadtoinconsist
encyint
he
database.
Thiskindofprobl
em isknownasupdateormodi fi
cati
onanomal y.
Sol
vi
nganomal
iesi
ndat
abasedesi
gn
Anomal
i
esi
ndat
abasedesi
gncanbesol
vedbyusi
ngnor
mal
i
zat
ion.
Normal ization
Databasenor mal
izat i
oni sthepr ocessofr emovi
ngr edundantdataf r
om t ablestoimprov e
storageef ficiency
, dataintegri
ty,andscalabi
l
ity
.
Inther elationalmodel ,met hodsexi stforquant
ifyi
nghow ef fi
cientadat abaseis.These
cl
assi f
icationsar ecal lednormalf orms(orNF),andtherearealgori
thmsf orconv er
ti
ngagiven
databasebet weent hem.
Normal izationgener al
lyinvol
vesspl i
tt
ingexist
ingt
ablesintomul t
ipl
eones,whi chmustber e-
j
oinedorl i
nkedeacht imeaquer yisissued.
NeedofNor
malizat
ion
o Eli
minatesredundantdata
o Reduceschancesofdat aerr
ors
o Reducesdiskspace
o Improvedataintegr
it
y,scal
abi
li
tyanddat
aconsi
stency
.
Ty
pesofnormalfor
ms
1NF,2NF,3NF,BCNF,
4NFand5NF
1NF-Ar elati
onRi sinfi
rstnor
mal f
orm(1NF)ifandonl
yifal
lunder
lyi
ngdomainscont
ain
atomi cvaluesonly.OR
Ar elati
onRi sinfir
stnormalform(1NF)ifandonl
yifi
tdoesnotcontai
nanycomposi
teor
multi-val
uedat t
ributesorthei
rcombinat
ions.
Exampl e
Aboverelati
onhasf ouratt
ri
butesCi
d,Name, Address,
Contact_
no.Hereaddr
essiscomposi
te
at
tri
butewhi chisfur
therdi
videdint
osubat t
ri
butesasSocietyandCit
y.
Anotherattr
ibuteContact
_noismultiv
aluedatt
ri
butewhichcanstoremorethanoneval
ues.
Soabov erel
ationisnotin1NF.
Pr
obl
em
36
Okor
onkwoM.C.Cos124
Supposewewanttof
indal
lcust
omersforsomepart
icul
arci
tyt
heni
tisdi
ff
icul
ttoret
riev
e.
Reasoni
sci
tynameiscombinedwi
thsoci
etynameandstor
edwholeasaddress.
Solut
ion
Insertsepar
ateat
tri
but
eforeachsubat
tri
but
eofcomposi
teat
tri
but
e.
I
nsertsepar
ateat
tri
buteformult
ival
uedat
tri
but
eandi
nser
tonl
yonev
alueononeat
tri
but
e
andotheri
notheratt
ri
bute.
Soabov
etabl
ecanbecr
eat
edasf
oll
ows.
2NF Ar
elat
ionRi
sinsecondnor
mal
for
m(2NF)i
fandonl
yifi
tisi
n1NFandev
erynon-
key
at
tri
but
eisf
ull
ydependentont
hepr
imar
ykey
.OR
Arel
ationRisi
nsecondnor
malfor
m(2NF)i
fandonl
yifi
tisi
n1NFandnonon-
keyat
tri
but
eis
par
ti
all
ydependentont
hepri
mar
ykey.
Exampl
e
Aboverelat
ionhasf
iveat
tri
but
esci
d,ano,
acess_
dat
e,bal
ance,
bnameandt
wof
unct
ional
dependencyFDS
FD1{
cid,
ano}{
acess_
dat
e,bal
ance,
bname}and
FD2ano{
bal
ance,
bname}
Probl
em
Forexampl
ei ncaseofjoi
ntaccountmult
ipl
ecustomer
shav ecommonaccounts.I
fsome
accountsays‘A02’isj
ointl
ybyt wocustomerssays‘C02’and‘C04’thendat
av al
uesfor
att
ri
butesbal
anceandbnamewi l
lbedupli
catedint
wodiff
erentt
uplesofcust
omers‘
C02’and
‘
C04’.
Sol
uti
on
o Decomposer el
ationinsuchawayt hatr esul
tantrelat
iondoesnothav eanyparti
alFD.
o Fort hi
spur poser emovepartialdependentat tr
ibutethatvi
olets2NFfrom r
elat
ion.
o Pl acethem insepar at
enewr elati
onal ongwi t
ht heprimeattri
buteonwhichtheyareful
l
dependent.
o Thepr imar ykeyofnewr elat
ionwi llbetheat t
ri
buteonwhi chitifful
l
ydependent.
o Keepot herattr
ibutesameasi nthattablewithsamepr i
marykey .
o Soabov etablecanbedecomposedasperf oll
owing.
37
Okor
onkwoM.C.Cos124
3NF Ar
elat
ionRi
sint
hir
dnor
mal
for
m(3NF)i
fandonl
yifi
tisi
n2NFandev
erynon-
key
at
tri
but
eisnon-
tr
ansi
ti
vel
ydependentont
hepr
imar
ykey
.
Anatt
ri
but
eCist
ransi
ti
vel
ydependentonat
tri
but
eAi
fther
eexi
stanat
tri
but
eBsucht
hat
:A
→ BandB→ C.
Exampl
e
Abov
erel
ati
onhasfouratt
ri
butesano,bal
ance,bname,baddr
essandt
woFDS
FD1ano→{ bal
ance,bname,baddr
ess}and
FD2bname→baddr ess
Sof
rom FD1andFD2andusi
ngt
ransi
ti
vi
tyr
ulewegetano→baddr
ess.
Sother
eist
ransit
ivel
ydependencyf
rom anot
obaddr
essusi
ngbnamei
nwhi
chbaddr
essi
s
non-
pri
meattr
ibut
e.
Sot
her
eisanon-
pri
meat
tri
but
ebaddr
esswhi
chi
str
ansi
ti
vel
ydependentonpr
imar
ykeyano.
Soabov
erel
ati
oni
snoti
n3NF.
Pr
obl
em
Tr
ansi
ti
vel
ydependencyr
esul
tsi
ndat
aredundancy
.
I
nthi
srel
ati
onbranchaddr
esswil
lbest
oredr
epeat
edl
yfr
om eachaccountofsamebr
anch
whichoccupymorespace.
Sol
uti
on
o Decomposer el
ationinsuchawayt hatresult
antrel
ationdoesnothav eanynon-pri
me
attr
ibutethatar etransi
ti
vel
ydependentonpr imarykey .
o Forthispur poser emovetransi
t i
velydependentattr
ibutethatvi
olets3NFfrom r
elat
ion.
o Placethem i nsepar at
enewr elati
onalongwi ththenon-primeattri
buteduetowhich
tr
ansiti
v edependencyoccur red.Thepr imarykeyofnewr el
ati
onwi l
lbethi
snon-pri
me
attr
ibute.
o Keepot herat tr
ibutessameasi nt hattabl
ewi t
hsamepr i
mar ykey.
o Soabov etablecanbedecomposedasperf oll
owing.
38
Okor
onkwoM.C.Cos124
BCNFAr
elat
ionRi
sinBCNFi
fandonl
yifi
tisi
n3NFandnopr
imeat
tri
but
eist
ransi
ti
vel
y
dependentonthepri
marykey.
Anattri
buteCistr
ansi
ti
vel
ydependentonat
tri
but
eAi
fther
eexi
stanat
tri
but
eBsucht
hat
A→BandB→C.
Example
Abov
erel
ati
onhasfi
veattr
ibut
escid,
ano,acess_
dat
e,bal
ance,
bnameandt
woFDS
FD1{st
udent
,l
anguage}→guideand
FD2gui
de→l anguage
Sof
rom FD1andFD2andusi
ngt
ransi
ti
vi
tyr
ulewegetst
udent→l
anguage
Sother
eist
ransi
ti
vel
ydependencyf
rom st
udentt
olanguagei
nwhi
chl
anguagei
spr
ime
at
tri
but
e.
Sot
her
eisonpr
imeat
tri
but
elanguagewhi
chi
str
ansi
ti
vel
ydependentonpr
imar
ykeyst
udent
.
Soabov
erel
ati
oni
snoti
nBCNF.
Pr
obl
em
Tr
ansi
ti
vel
ydependencyr
esul
tsi
ndat
aredundancy
.
Int
hisrel
ati
ononest
udenthav
emor ethanoneproj
ectwit
hdi f
fer
entguidethenr
ecor
dswill
bestor
edrepeat
edl
yfr
om eachstudentandlanguageandguidescombinati
onwhichoccupi
es
morespace.
Sol
uti
on
o Decomposer elat
ioninsuchawayt hatresult
antrelat
iondoesnothaveanyprime
att
ri
butetr
ansitiv
elydependentonprimarykey.
o Forthi
spurposer emovetransi
ti
vel
ydependentpr imeattri
but
ethatvi
olet
sBCNFf rom
rel
ati
on.Pl
acet hem inseparat
enewr el
ationalongwiththenon-
pri
meat t
ribut
edueto
whichtr
ansit
ivedependencyoccurred.Theprimarykeyofnewr el
ati
onwillbethi
s
nonpri
meat t
ribute.
o Soabovetablecanbedecomposedasperf oll
owing.
39
Okor
onkwoM.C.Cos124
40
Okor
onkwoM.C.Cos124
STRUCTUREDQUERRYLANGUAGE(
SQL)
Hi
stor
icalNot
e
Theorigi
nsofSQLcanbet racedt oanIBM resear
chpaperpubli
shedin1974,ti
ted SEQUEL:A
l
Str
uct
uredEngl
i
shQueryLanguage,byDonaldD.Chamberl
inandRaymondF.Boyce.RaymondBoyce,
whosadlydi
edint
hesamey ear,1974,wast
hepersonwhosenameisenshr
i nBoy
nedi ce-
CoddNor mal
Form(BCNF)
Aprot
otypeimpl
ementationofSEQUEL,namedSEQUEL-XRM,waspr oducedin1974–75.Experi
ence
wi
ththi
spr ot
oty
pel edin1976–77t oar evi
sedver
sionoft helanguage,SEQUEL/
2,subsequentl
y
r
enamedSQLf orlegalreasons.WorkthenbeganonSystem R,another
,mor eambi
tiouspr
ototype,
i
mplementi
ngasubsetoft hatr
evi
sedv
ersi
on.
……
I
n1996addi ti
onalfeatur
esknownasSQL/ PSM ( aprogrammi nglanguagef orstor
edpr oceduresand
functi
ons)andSQL/ CLI(a“ calll
eveli
nterf
ace”)wer eadded.Att hesamet i
me,thecommi tt
eewas
wor ki
ngonf urt
herex t
ensionst othelanguage,result
ingintheappear anceof“ SQL/3”asSQL:1999,
whosemostsi gni
fi
cantaddi ti
onwast heso- cal
led“object
-r
elati
onal”featur
esuppor t
inguserdef i
ned
types.Furt
herrevi
sionsappear edin2003,2007,and2011.Thatl astone,SQL:2011( r
eference[15]
),i
s
notablefori
tsmodicum ofsuppor tfor“
temporaldatabase”management .
Manyoft
headditi
onalfeat
uresappeari
nginpost
-1989edit
ionsarespeci
fi
edasopt
ional
,meani
ngt
hat
t
heyar
en’
trequi
redforanimplementat
iont
oquali
fyasstandard-
conf
orming.
Histor
icalnotesappeari
ngl at
er,concerni
ngspecifi
cf eatur
esofSQL,ref
ermost l
ytothepre-
2000
edit
ionsoft heI
SOSQLst andard:1987,1989,1992,1996,1999,t
houghi
nconnect
ionwi
ththenot
ati
on
forqueriescansometi
mest akeyourightbacktothe1974SEQUELpaper.
SQLDat
abase
AnSQLdat
abasei
sonewhosesy
mbol
sar
eor
gani
zedi
ntoacol
l
ect
ionoft
abl
es.
SQLI
saDat
abaseLanguage
Whyt
heconcer
nedaboutSQL?
Untilrecentl
y,ify ouweren'
tworki
ngonal ar
gedat abasesystem,y ouprobablyhadonl yapassi ng
knowledgeofSQL.Wi tht
headventofcli
ent
/ser
verdev el
opmenttools(suchasVi sualBasic,Vi
sualC++,
ODBC,Bor l
and'sDelphi
,andPowersoft
'sPowerBui
lder)andthemov ementofsev erallargedatabases
(OracleandSy base)t
ot hePCplat
form,mostbusinessapplicati
onsbeingdev elopedt odayrequir
ea
wor ki
ngknowl edgeofSQL.
WhatDoesanSQLDBMSDo?
I
nresponset
orequest
sfr
om appl
i
cat
ionpr
ogr
ams,
anSQLDBMScan,
forex
ampl
e,
41
Okor
onkwoM.C.Cos124
o creat
eanddest roybaset abl
es
o Changesystem secur i
tysett
ings
o Adduserpermi ssionsondat abasesort abl
es
o takenoteofintegrityrulesexpressedasconstraint
s
o takenoteofaut horisati
ons(whoi sallowedtodowhat ,towhat
)
o updatevari
ables( honour i
ngconst r
aintsandauthori
sat
ions)
o provi
deresulsofquer
t i
es
Int
heremaini
ngsection, youwi ll
seeex amplesofhowanSQLDBMSdoest heset
hings(
via
commands—usuall
ycal ledst atements—wr i
tteninSQL,ofcour
se).
SQLi
nAppl
icat
ionPr
ogr
ammi
ng
SQLwasor i
ginall
ymadeanANSIstandar
din1986.TheANSI1989standar
d(of
tencal
l
edSQL-
89)
def
inest
hreet y
pesofint
erf
aci
ngtoSQLwi t
hinanappl
icat
ionpr
ogr
am:
Modul
eLanguage-Usespr
ocedur
eswi
thi
npr
ogr
ams.Thesepr
ocedur
escanbecal
l
edbyt
he
applicati
onpr ogr am andcanr etur
nv al
uestot heprogr
am viapar ameterpassing.
Embe ddedSQL- UsesSQLst atement sembeddedwi thact
ual program code.Thismet hodoften
requirestheuseofapr ecompilertoprocesst heSQLstat
ement s.Thest andarddef i
nesstat
ements
forPascal ,PHP, Jav a,
FORTRAN, COBOL, andPL/ 1.
Di rectInvocation-Leftuptothei mplementer.
Befor et heconceptofdy nami cSQLev olv
ed,embeddedSQLwast hemostpopul arwayt ouseSQL
withinapr ogram.EmbeddedSQL,whi chisstilused,usesst
l aticSQL( theSQLst atementiscompiled
i
ntot heappl i
cati
onandcannotbechangedatr unti
me).Theprinciplei
smucht hesameasacompi l
er
versusani nterpr
et er.Theperformancef orthi
sty peofSQLisgood; howev er,i
tisnotf l
exi
bleandcannot
alway smeett heneedsoft oday'
schangi ngbusinessenvir
onment s.
TheANSI1992standar
d(SQL-
92)extendedthelanguageandbecameanint
ernat
ional
standard.I
t
defi
nesthr
eelev
elsofSQLcompl
iance:ent
ry,i
ntermediat
e,andf
ull
.Thenewfeat
uresint
roducedincl
ude
thefol
l
owing:
Connect
ionst
odat
abases
Scr
oll
abl
ecur
sor
s
Dy
nami
cSQL
Out
erj
oins
DynamicSQLal l
owsy outoprepar
et heSQLst atementatr unti
me.Al
thought heper
formanceforthi
s
ty
peofSQLi snotasgoodast hatofembeddedSQL,i tprovidest
heapplicat
iondevel
oper(anduser
)
wit
hagr eatdegreeoff l
exi
bil
i
ty.Acall-
lev
elinterf
ace,suchasopendat abaseconnecti
vi
tyODBCor
Sybase'
sDB-Li
brary
,isanexampleofdynamicSQL.
Call
-levelinterf
acesshouldnotbeanew conceptt oapplicati
onpr ogr
ammer s.WhenusingODBC,for
i
nstance,y ousimpl yfi
l
lav ari
ablewithy ourSQLst at
ementandcal lthefuncti
ont osendtheSQL
statementt othedatabase.Er
rorsorresultscanbereturnedt otheprogram thr
oughtheuseofother
functioncal l
sdesignedfort
hosepurposes.Resul
tsarereturnedthroughaprocessknownasthebi
nding
ofvar i
ables.
ComponentofSQL
DDL(DataDefi
nit
ionLanguage)
I
tisasetofSQLcommandsusedt ocreat
e,modi
fyanddel
etedat
abaseobj
ect
ssuchas
t
ables,
views,i
ndices,
etc.
I
tisnormall
yusedbyDBAanddatabasedesi
gner
s.
42
Okor
onkwoM.C.Cos124
I
tpr
ovi
descommandsl
i
ke:
CREATE:
tocr
eat
eobj
ect
sinadat
abase.
ALTER:
toal
tert
heschema,
orl
ogi
cal
str
uct
ure,
oft
hedat
abase.
DROP:
todel
eteobj
ect
sfr
om t
hedat
abase.
TRUNCATE:
tor
emov
eal
lrecor
dsf
rom t
het
abl
e.
DML(DataManipul
ati
onLanguage)
I
tisasetofSQLcommandsusedt oi
nser
t,modi
fyanddel
etedat
ainadat
abase.
I
tisnor
mallyusedbygener
aluser
swhoar
eaccessi
ngdat
abasev
iapr
e-dev
eloped
appli
cati
ons.
I
tpr
ovi
descommandsl
i
ke:
I
NSERT:
toi
nser
tdat
aint
oat
abl
e.
UPDATE:
tomodi
fyexi
sti
ngdat
ainat
abl
e.
DELETE:
todel
eter
ecor
dsf
rom at
abl
e.
LOCK:
tol
ockt
abl
est
opr
ovi
deconcur
rencycont
rol
amongmul
ti
pleuser
s.
DQL(Dat
aQueryLanguage)OrDDL(Dat
aRetri
evalLanguage
I
tisacomponentofSQLthatal
lowsdatar
etri
evalfr
om thedat
abase.
I
tpr
ovi
descommandl i
ke:
SELECT.Thi
scommandi
sahear
tofSQL,
andal
l
owsdat
aret
ri
eval
indi
ff
erent
ways.
DCL(DataCont
rolLanguage)
I
tissetofSQLcommandsusedt ocont
rol
accesst
odat
aanddat
abase.Occasi
onal
l
yDCL
commandsaregroupedwi t
hDMLcommands.
I
tprovi
descommandsl ike:
COMMI
T:t
osav
ewor
kper
manent
ly.
ROLLBACK:
toundowor
kandr
est
oredat
abaset
opr
evi
ousst
ate.
SAVEPOI
NT:
toi
dent
if
yapoi
nti
nat
ransact
iont
owhi
chwor
kcanbeundone.
GRANT:
togi
veaccesspr
ivi
l
egest
ouser
sont
hedat
abase.
REVOKE:
towi
thdr
awaccesspr
ivi
l
egesgi
vent
ouser
sont
hedat
abase
Cl
assi
fi
cat
ionofSQLSt
atement
s
Key
wor
ds/
Commands Funct
ion Remar
ks
1 SELECT,
FROM Dat
aRet
ri
eval
(DR) Retr
iev
edat
afrom tabl
esandv i
ewsof
DBs
2 I
NSERT,UPDATE, Dat
aMani
pul
ati
on(
DM) Usedtomani
pulat
eex i
sti
ngrecords.
DELETE,
MERGE
3 CREATE,ALTER, Dat
aDef
ini
ti
on(
DD) Uset
o:set
,changesandr
emov
est
abl
e
43
Okor
onkwoM.C.Cos124
DROP,RENAME st
ruct
ures.
TRUNCATE
4 COMMIT, ROLLBACK Transact
ionCont
rol Managest
hechangesmadebyDM.
SAVEPOINT (TC)
5 GRANT,REVOKE Datacontrol
(DC) Giv
esorremovesr
ightt
obot
hdbase
andst
ructur
es.
Cr
eat
ingandDest
roy
ingBaseTabl
es
SQLCREATETABLE
Thecreatetabl
estat
ementisusedt
ocreateanewt abl
e.Thestatementdef
inesat abl
e.Thedefi
nit
ion
mustincludeit
snameandt henamesandat t
ri
butesofit
scolumns.Thedef ini
ti
oncani ncl
udeother
at
tri
butesofthetabl
e,suchasi
tspr
imarykey(orcheckconst
raints)
.Thi
sstatementcomesundert he
DDLstatement.
Sy
ntax:
SQL>Cr
eat
etabl
e<t
abl
ename>
(Col
umn1dat
aty
pe[
def
aul
texp][
Const
rai
nt]
,
Col
umn2dat
aty
pe[
def
aul
texp][
Const
rai
nt]
,
Col
umn3dat
aty
pe[
def
aul
texp][
Const
rai
nt]
,
)
;
Exampl
e:
I
fyouwantt
oseet
hest
ruct
ureoft
het
abl
ethenuset
hef
oll
owi
ngcommandonSQLpr
ompt
.
SQL>DESCempl
oyee;
Theabov
ecommanddisplaystheent
ir
eat
tri
but
enameswi
tht
hei
rdat
aty
peandi
fconst
rai
ntsar
e
i
mposedthent
hei
rdet
ailalso.
Youcanalsocreat
eat ablefr
om anexist
ingtablebycopyingt
heexi
sti
ngtabl
e'
scolumns.Iti
s
i
mportanttonotet
hatwhencr eat
ingatablei
nthisway ,
thenewtabl
ewil
lbepopul
atedwithther
ecor
ds
fr
om t
heex i
sti
ngtabl
e( basedontheSELECTSt atement)
.
Sy
ntax#1-Copy
ingal
lcol
umnsf
rom anot
hert
abl
e
44
Okor
onkwoM.C.Cos124
SQL>CREATETABLEnew_
tabl
e
AS(
SELECT*FROM ol
d_t
abl
e);
Exampl
e:
SQL>CREATETABLEper
sons
AS(
sel
ect*f
rom empl
oyee)
;
Thecommandwoul
dcr
eat
eanewt
abl
ecal
l
edper
sonst
hati
ncl
udedal
lcol
umnsf
rom t
heper
sonst
abl
e.
I
ftherewererecor
dsint
heol
dtabl
e,t
hent
henewt
abl
ewoul
dal
socont
aint
her
ecor
dssel
ect
edbyt
he
SELECTstatement.
Sy
ntax#2-Copy
ingSel
ect
edcol
umnsf
rom anot
hert
abl
e
SQL>Cr eateTableTabl
ename
(<columnname1>"columnname2>)asselect
Statement ;
Where<columnnamel >,col
umnname2>ar ethenewcol
umnsinnewt
abl
ewi
thnewnamet
obe
associ
atedwit
hthev aluesret
urnedbythesubquer
y.
Exampl
e:
SQL>CreateTablePer
sons
(Per
son_i
d,name)
ASSELECT( P_I
d,Fi
rst
Name)f
rom per
sons;
Not
e:Cr
eat
ingat
abl
efr
om anot
hert
abl
ewi
thoutcopy
inganyv
aluesf
rom t
heol
dtabl
e:
Exampl
e:
SQL>CREATETABLEpersons
AS(sel
ect*f
rom per
sonswhere1=2)
;
Tr
ansact
ionCont
rolCommands
Transact
ionContr
olCommands(TCL)i
sasetofSQLcommandst
hatar
eusedt
ocont
rol
tr
ansacti
onalpr
ocessi
ngi
nadatabase.
Atransact
ionisl
ogi
cal
unitofworkthatconsi
stsofoneormor
eSQLst
atement
s,usual
l
ya
gr
oupofDat aMani
pulat
ionLanguage(DML)statement
s.
Tr
ansact
ionCont
rol
Commands(
TCL)commandsi
ncl
ude
SQL>DELETEFROM STUDENTWHERESPI<8;
SQL>COMMI T;
Out
put
:
45
Okor
onkwoM.C.Cos124
2.ROLLBACK:TheROLLBACKcommandi sthetr
ansacti
onalcont
rolcommandusedt
oundo
tr
ansact
ionst
hathav
enotalr
eadybeensavedtothedatabase.
TheROLLBACKcommandcanonl ybeusedtoundotransacti
onssi
ncethel
astCOMMITor
ROLLBACKcommandwasi ssued.
SQL>DELETEFROM STUDENTWHERESPI<8;
SQL>COMMI T;
Output
:
3.SAVEPOINT:ASAVEPOINTisapoi
ntinatransacti
onwhenyoucanr
oll
thet
ransact
ionback
toacertai
npoi
ntwi
thoutr
oll
i
ngbacktheenti
retransact
ion.
Example:
SQL>SAVEPOINTSAVEPOINT_NAME;
SQL>ROLLBACKTOSAVEPOI NT_ NAME;
Dat
aCont
rolLanguage(
DCL)Commands.
DCLcommandsar eusedtoenf
orce(
impl
ement
)dat
abasesecur
it
yinamul
ti
pleuser
dat
abaseenv
ironment.
Thesecommandsar
eusedt
ogi
veort
akebackper
missi
ononanyobj
ectt
o/f
rom anyuser
.
Twot
ypesofDCLcommandsar
eGRANTandREVOKE.
OnlyDat
abaseAdmini
str
ator
'sorowneroft
hedat
abaseobj
ectcanpr
ovi
de/
remov
epr
ivi
l
eges
onadatabaseobj
ect
.
obj
ect_namei
sthenameofandat
abaseobj
ectl
i
keTABLE,
VIEW,
STOREDPROCandSEQUENCE.
user
_namei
sthenameoft
heusert
owhom anaccessr
ighti
sgr
ant
ed.
PUBLI
Cisusedt
ogr
antaccessr
ight
stoal
luser
s.
WI
THGRANTOPTI
ON-al
l
owsausert
ogr
ant(
giv
e)accessr
ight
stoot
heruser
s.
47