You are on page 1of 34

0atabase 8ystem 6oncepts, 5th Ed.

@8||berschatz, Korth and 8udarshan


8ee www.db-book.comfor cond|t|ons on re-use
6hapter 1: |ntroduct|on 6hapter 1: |ntroduct|on
@8||berschatz, Korth and 8udarshan 1.2 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
6hapter 1: |ntroduct|on 6hapter 1: |ntroduct|on
Purpose ol 0alaoase 3yslers
0alaoase Larguages
Re|al|ora| 0alaoases
0alaoase 0es|gr
0ala Vode|s
0alaoase lrlerra|s
0alaoase users ard Adr|r|slralors
0vera|| 3lruclure
l|slory ol 0alaoase 3yslers
@8||berschatz, Korth and 8udarshan 1.3 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase Hanagement 8ystem (0H8} 0atabase Hanagement 8ystem (0H8}
08V3 corla|rs |rlorral|or aooul a parl|cu|ar erlerpr|se
Co||ecl|or ol |rlerre|aled dala
3el ol progrars lo access lre dala
Ar erv|rorrerl lral |s oolr oonven|enr ard ell|o|enr lo use
0alaoase App||cal|ors:
8ar||rg: a|| lrarsacl|ors
A|r||res: reserval|ors, scredu|es
ur|vers|l|es: reg|slral|or, grades
3a|es: cuslorers, producls, purcrases
0r||re rela||ers: order lrac||rg, cuslor|zed recorrerdal|ors
Varulaclur|rg: producl|or, |rverlory, orders, supp|y cra|r
lurar resources: erp|oyee records, sa|ar|es, lax deducl|ors
0alaoases loucr a|| aspecls ol our ||ves
@8||berschatz, Korth and 8udarshan 1.4 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
Purpose of 0atabase 8ystems Purpose of 0atabase 8ystems
lr lre ear|y days, dalaoase app||cal|ors Were ou||l d|recl|y or lop ol l||e syslers
0raWoac|s ol us|rg l||e syslers lo slore dala:
0ala redurdarcy ard |rcors|slercy
Vu|l|p|e l||e lorrals, dup||cal|or ol |rlorral|or |r d|llererl l||es
0|ll|cu|ly |r access|rg dala
eed lo Wr|le a reW prograr lo carry oul eacr reW las|
0ala |so|al|or ru|l|p|e l||es ard lorrals
lrlegr|ly proo|ers
lrlegr|ly corslra|rls (e.g. accourl oa|arce > 0) oecore 'our|ed |r prograr
code ralrer lrar oe|rg slaled exp||c|l|y
lard lo add reW corslra|rls or crarge ex|sl|rg ores
@8||berschatz, Korth and 8udarshan 1.5 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
Purpose of 0atabase 8ystems (6ont.} Purpose of 0atabase 8ystems (6ont.}
0raWoac|s ol us|rg l||e syslers (corl.)
Alor|c|ly ol updales
a||ures ray |eave dalaoase |r ar |rcors|slerl slale W|lr parl|a| updales carr|ed
oul
Exarp|e: Trarsler ol lurds lror ore accourl lo arolrer srou|d e|lrer corp|ele
or rol rapper al a||
Corcurrerl access oy ru|l|p|e users
Corcurrerl accessed reeded lor perlorrarce
urcorlro||ed corcurrerl accesses car |ead lo |rcors|slerc|es
- Exarp|e: TWo peop|e read|rg a oa|arce ard updal|rg |l al lre sare l|re
3ecur|ly proo|ers
lard lo prov|de user access lo sore, oul rol a||, dala
0alaoase syslers oller so|ul|ors lo a|| lre aoove proo|ers
@8||berschatz, Korth and 8udarshan 1. 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
Leve|s of Abstract|on Leve|s of Abstract|on
Phys|ca| |eve|: descr|oes roW a record (e.g., cuslorer) |s slored.
Log|ca| |eve|: descr|oes dala slored |r dalaoase, ard lre re|al|orsr|ps arorg lre dala.
type ousromer record
ousromer_|o : slr|rg;
ousromer_name : slr|rg;
ousromer_srreer : slr|rg;
ousromer_o|ry : slr|rg;
end;
'|ew |eve|: app||cal|or progrars r|de dela||s ol dala lypes. v|eWs car a|so r|de
|rlorral|or (sucr as ar erp|oyee's sa|ary) lor secur|ly purposes.
@8||berschatz, Korth and 8udarshan 1.7 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
'|ew of 0ata '|ew of 0ata
Ar arcr|leclure lor a dalaoase sysler
@8||berschatz, Korth and 8udarshan 1.8 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
|nstances and 8chemas |nstances and 8chemas
3|r||ar lo lypes ard var|ao|es |r prograrr|rg |arguages
8chema - lre |og|ca| slruclure ol lre dalaoase
Exarp|e: Tre dalaoase cors|sls ol |rlorral|or aooul a sel ol cuslorers ard accourls ard lre
re|al|orsr|p oelWeer lrer)
Ara|ogous lo lype |rlorral|or ol a var|ao|e |r a prograr
Phys|ca| schema: dalaoase des|gr al lre prys|ca| |eve|
Log|ca| schema: dalaoase des|gr al lre |og|ca| |eve|
|nstance - lre aclua| corlerl ol lre dalaoase al a parl|cu|ar po|rl |r l|re
Ara|ogous lo lre va|ue ol a var|ao|e
Phys|ca| 0ata |ndependence - lre ao|||ly lo rod|ly lre prys|ca| screra W|lroul crarg|rg lre |og|ca|
screra
App||cal|ors deperd or lre |og|ca| screra
lr gerera|, lre |rlerlaces oelWeer lre var|ous |eve|s ard corporerls srou|d oe We|| del|red so
lral crarges |r sore parls do rol ser|ous|y |rl|uerce olrers.
@8||berschatz, Korth and 8udarshan 1.9 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0ata Hode|s 0ata Hode|s
A co||ecl|or ol loo|s lor descr|o|rg
0ala
0ala re|al|orsr|ps
0ala serarl|cs
0ala corslra|rls
Re|al|ora| rode|
Erl|ly-Re|al|orsr|p dala rode| (ra|r|y lor dalaoase des|gr)
0ojecl-oased dala rode|s (0ojecl-or|erled ard 0ojecl-re|al|ora|)
3er|slruclured dala rode| (XVL)
0lrer o|der rode|s:
elWor| rode|
l|erarcr|ca| rode|
@8||berschatz, Korth and 8udarshan 1.10 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0ata Han|pu|at|on Language (0HL} 0ata Han|pu|at|on Language (0HL}
Larguage lor access|rg ard rar|pu|al|rg lre dala orgar|zed oy lre appropr|ale dala
rode|
0VL a|so |roWr as query |arguage
TWo c|asses ol |arguages
Procedura| - user spec|l|es Wral dala |s requ|red ard roW lo gel lrose dala
0ec|arat|ve (nonprocedura|} - user spec|l|es Wral dala |s requ|red W|lroul
spec|ly|rg roW lo gel lrose dala
30L |s lre rosl W|de|y used query |arguage
@8||berschatz, Korth and 8udarshan 1.11 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0ata 0ef|n|t|on Language (00L} 0ata 0ef|n|t|on Language (00L}
3pec|l|cal|or rolal|or lor del|r|rg lre dalaoase screra
Exarp|e: create tab|e aooounr (
aooounr_numoer char(10),
oranon_name char(10),
oa|anoe |nteger)
00L corp||er gererales a sel ol lao|es slored |r a oara o|or|onary
0ala d|cl|orary corla|rs reladala (|.e., dala aooul dala)
0alaoase screra
0ala srorae ano oel|n|r|on |arguage
3pec|l|es lre slorage slruclure ard access relrods used
lrlegr|ly corslra|rls
0ora|r corslra|rls
Relererl|a| |rlegr|ly (e.g. oranon_name rusl correspord lo a va||d orarcr |r
lre oranon lao|e)
Aulror|zal|or
@8||berschatz, Korth and 8udarshan 1.12 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
Re|at|ona| Hode| Re|at|ona| Hode|
Exarp|e ol laou|ar dala |r lre re|al|ora| rode|
Allr|oules
@8||berschatz, Korth and 8udarshan 1.13 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
A 8amp|e Re|at|ona| 0atabase A 8amp|e Re|at|ona| 0atabase
@8||berschatz, Korth and 8udarshan 1.14 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
80L 80L
80L: W|de|y used ror-procedura| |arguage
Exarp|e: |rd lre rare ol lre cuslorer W|lr cuslorer-|d 192-83-Z15
se|ect ousromer.ousromer_name
from ousromer
where ousromer.ousromer_|o '192-83-Z15'
Exarp|e: |rd lre oa|arces ol a|| accourls re|d oy lre cuslorer W|lr cuslorer-|d 192-
83-Z15
se|ect aooounr.oa|anoe
from oepos|ror, aooounr
where oepos|ror.ousromer_|o '192-83-Z15' and
oepos|ror.aooounr_numoer = aooounr.aooounr_numoer
App||cal|or progrars gerera||y access dalaoases lrrougr ore ol
Larguage exlers|ors lo a||oW eroedded 30L
App||cal|or prograr |rlerlace (e.g., 008C/J08C) Wr|cr a||oW 30L quer|es lo oe serl lo a
dalaoase
@8||berschatz, Korth and 8udarshan 1.15 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase 0es|gn 0atabase 0es|gn
Tre process ol des|gr|rg lre gerera| slruclure ol lre dalaoase:
Log|ca| 0es|gr - 0ec|d|rg or lre dalaoase screra. 0alaoase des|gr requ|res lral We
l|rd a 'good co||ecl|or ol re|al|or screras.
8us|ress dec|s|or - wral allr|oules srou|d We record |r lre dalaoase?
Corpuler 3c|erce dec|s|or - wral re|al|or screras srou|d We rave ard roW
srou|d lre allr|oules oe d|slr|ouled arorg lre var|ous re|al|or screras?
Prys|ca| 0es|gr - 0ec|d|rg or lre prys|ca| |ayoul ol lre dalaoase
@8||berschatz, Korth and 8udarshan 1.1 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
The Ent|ty The Ent|ty--Re|at|onsh|p Hode| Re|at|onsh|p Hode|
Vode|s ar erlerpr|se as a co||ecl|or ol enr|r|es ard re|ar|onsn|ps
Erl|ly: a 'lr|rg or 'oojecl |r lre erlerpr|se lral |s d|sl|rgu|srao|e lror olrer
oojecls
0escr|oed oy a sel ol arrr|oures
Re|al|orsr|p: ar assoc|al|or arorg severa| erl|l|es
Represerled d|agrarral|ca||y oy ar enr|ry-re|ar|onsn|p o|aram.
@8||berschatz, Korth and 8udarshan 1.17 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0ther 0ata Hode|s 0ther 0ata Hode|s
0ojecl-or|erled dala rode|
0ojecl-re|al|ora| dala rode|
@8||berschatz, Korth and 8udarshan 1.18 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase App||cat|on Arch|tectures 0atabase App||cat|on Arch|tectures
(web browser)
0|d
Voderr
@8||berschatz, Korth and 8udarshan 1.19 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase Hanagement 8ystem |nterna|s 0atabase Hanagement 8ystem |nterna|s
3lorage raragererl
0uery process|rg
Trarsacl|or process|rg
@8||berschatz, Korth and 8udarshan 1.20 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
8torage Hanagement 8torage Hanagement
8torage manager |s a prograr rodu|e lral prov|des lre |rlerlace oelWeer lre |oW-
|eve| dala slored |r lre dalaoase ard lre app||cal|or progrars ard quer|es suor|lled
lo lre sysler.
Tre slorage rarager |s respors|o|e lo lre lo||oW|rg las|s:
lrleracl|or W|lr lre l||e rarager
Ell|c|erl slor|rg, relr|ev|rg ard updal|rg ol dala
lssues:
3lorage access
||e orgar|zal|or
lrdex|rg ard rasr|rg
@8||berschatz, Korth and 8udarshan 1.21 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0uery Process|ng 0uery Process|ng
1. Pars|rg ard lrars|al|or
2. 0pl|r|zal|or
3. Eva|ual|or
@8||berschatz, Korth and 8udarshan 1.22 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0uery Process|ng (6ont.} 0uery Process|ng (6ont.}
A|lerral|ve Ways ol eva|ual|rg a g|ver query
Equ|va|erl express|ors
0|llererl a|gor|lrrs lor eacr operal|or
Cosl d|llererce oelWeer a good ard a oad Way ol eva|ual|rg a query car oe erorrous
eed lo esl|rale lre cosl ol operal|ors
0eperds cr|l|ca||y or slal|sl|ca| |rlorral|or aooul re|al|ors Wr|cr lre dalaoase rusl
ra|rla|r
eed lo esl|rale slal|sl|cs lor |rlerred|ale resu|ls lo corpule cosl ol corp|ex
express|ors
@8||berschatz, Korth and 8udarshan 1.23 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
Transact|on Hanagement Transact|on Hanagement
A transact|on |s a co||ecl|or ol operal|ors lral perlorrs a s|rg|e |og|ca| lurcl|or |r a
dalaoase app||cal|or
Transact|on-management component ersures lral lre dalaoase rera|rs |r a
cors|slerl (correcl) slale desp|le sysler la||ures (e.g., poWer la||ures ard operal|rg
sysler crasres) ard lrarsacl|or la||ures.
6oncurrency-contro| manager corlro|s lre |rleracl|or arorg lre corcurrerl
lrarsacl|ors, lo ersure lre cors|slercy ol lre dalaoase.
@8||berschatz, Korth and 8udarshan 1.24 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0vera|| 8ystem 8tructure 0vera|| 8ystem 8tructure
@8||berschatz, Korth and 8udarshan 1.25 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
h|story of 0atabase 8ystems h|story of 0atabase 8ystems
1950s ard ear|y 190s:
0ala process|rg us|rg ragrel|c lapes lor slorage
Tapes prov|de or|y sequerl|a| access
Purcred cards lor |rpul
Lale 190s ard 19Z0s:
lard d|s|s a||oW d|recl access lo dala
elWor| ard r|erarcr|ca| dala rode|s |r W|despread use
Ted Codd del|res lre re|al|ora| dala rode|
wou|d W|r lre ACV Tur|rg AWard lor lr|s Wor|
l8V Researcr oeg|rs 3ysler R prololype
uC 8er|e|ey oeg|rs lrgres prololype
l|gr-perlorrarce (lor lre era) lrarsacl|or process|rg
@8||berschatz, Korth and 8udarshan 1.2 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
h|story (cont.} h|story (cont.}
1980s:
Researcr re|al|ora| prololypes evo|ve |rlo correrc|a| syslers
30L oecores |rduslry slardard
Para||e| ard d|slr|ouled dalaoase syslers
0ojecl-or|erled dalaoase syslers
1990s:
Large dec|s|or supporl ard dala-r|r|rg app||cal|ors
Large ru|l|-leraoyle dala Warerouses
Erergerce ol weo correrce
2000s:
XVL ard X0uery slardards
Auloraled dalaoase adr|r|slral|or
lrcreas|rg use ol r|gr|y para||e| dalaoase syslers
weo-sca|e d|slr|ouled dala slorage syslers
0atabase 8ystem 6oncepts, 5th Ed.
@8||berschatz, Korth and 8udarshan
8ee www.db-book.comfor cond|t|ons on re-use
End of 6hapter 1 End of 6hapter 1
@8||berschatz, Korth and 8udarshan 1.28 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase Users 0atabase Users
Users are d|llererl|aled oy lre Way lrey expecl lo |rleracl W|lr
lre sysler
App||cat|on programmers - |rleracl W|lr sysler lrrougr 0VL ca||s
8oph|st|cated users - lorr requesls |r a dalaoase query |arguage
8pec|a||zed users - Wr|le spec|a||zed dalaoase app||cal|ors lral do rol l|l |rlo lre
lrad|l|ora| dala process|rg lrareWor|
ave users - |rvo|e ore ol lre perrarerl app||cal|or progrars lral rave oeer
Wr|ller prev|ous|y
Exarp|es, peop|e access|rg dalaoase over lre Weo, oar| le||ers, c|er|ca| slall
@8||berschatz, Korth and 8udarshan 1.29 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase Adm|n|strator 0atabase Adm|n|strator
Coord|rales a|| lre acl|v|l|es ol lre dalaoase sysler
ras a good urderslard|rg ol lre erlerpr|se's |rlorral|or resources ard reeds.
0alaoase adr|r|slralor's dul|es |rc|ude:
3lorage slruclure ard access relrod del|r|l|or
3crera ard prys|ca| orgar|zal|or rod|l|cal|or
0rarl|rg users aulror|ly lo access lre dalaoase
8ac||rg up dala
Vor|lor|rg perlorrarce ard respord|rg lo crarges
0alaoase lur|rg
@8||berschatz, Korth and 8udarshan 1.30 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0atabase Arch|tecture 0atabase Arch|tecture
Tre arcr|leclure ol a dalaoase syslers |s greal|y |rl|uerced oy
lre urder|y|rg corpuler sysler or Wr|cr lre dalaoase |s rurr|rg:
Cerlra||zed
C||erl-server
Para||e| (ru|l|p|e processors ard d|s|s)
0|slr|ouled
@8||berschatz, Korth and 8udarshan 1.31 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
0bject 0bject--Re|at|ona| 0ata Hode|s Re|at|ona| 0ata Hode|s
Exlerd lre re|al|ora| dala rode| oy |rc|ud|rg oojecl or|erlal|or ard corslrucls lo dea|
W|lr added dala lypes.
A||oW allr|oules ol lup|es lo rave corp|ex lypes, |rc|ud|rg ror-alor|c va|ues sucr as
resled re|al|ors.
Preserve re|al|ora| lourdal|ors, |r parl|cu|ar lre dec|aral|ve access lo dala, Wr||e
exlerd|rg rode||rg poWer.
Prov|de upWard corpal|o|||ly W|lr ex|sl|rg re|al|ora| |arguages.
@8||berschatz, Korth and 8udarshan 1.32 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
XHL: Extens|b|e Harkup Language XHL: Extens|b|e Harkup Language
0el|red oy lre www Corsorl|ur (w3C)
0r|g|ra||y |rlerded as a docurerl rar|up |arguage rol a dalaoase |arguage
Tre ao|||ly lo spec|ly reW lags, ard lo creale resled lag slruclures rade XVL a
greal Way lo excrarge data, rol jusl docurerls
XVL ras oecore lre oas|s lor a|| reW gereral|or dala |rlercrarge lorrals.
A W|de var|ely ol loo|s |s ava||ao|e lor pars|rg, oroWs|rg ard query|rg XVL
docurerls/dala
@8||berschatz, Korth and 8udarshan 1.33 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
F|gure 1.4 F|gure 1.4
@8||berschatz, Korth and 8udarshan 1.34 0atabase 8ystem 6oncepts - 5
th
Ed|t|on, Hay 23, 2005
F|gure 1.7 F|gure 1.7

You might also like