ER Exercises - Part 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

rob|em 1

O A company daLabase needs Lo sLore lnformaLlon abouL employees (ldenLlfled by sso wltb soloty ooJ
pbooe os otttlbotes) Jepottmeots (lJeotlfleJ by Joo wlLh Joome ooJ boJqet os otttlbotes) ooJ
cbllJteo of employees (wltb oome ooJ oqe as aLLrlbuLes)
O mployees wotk lo Jepottmeots eocb Jepottmeot ls moooqeJ by oo employee a chlld musL be
ldenLlfled unlquely by oome wbeo tbe poteot (wbo ls oo employee assume LhaL only one parenL
works for Lhe company) ls known We are noL lnLeresLed ln lnformaLlon abouL a chlld once Lhe
parenL leaves Lhe company
O raw an dlagram LhaL capLures Lhls lnformaLlon

AssumpLlons
#mployees wotk lo Jepottmeots
#eocb Jepottmeot ls moooqeJ by oo employee"
#a chlld musL be ldenLlfled unlquely by oome wbeo tbe poteot (wbo ls oo employee assume
LhaL only one parenL works for Lhe company) ls known"



rob|em 2
O onslder Lhe scenarlo from above problem where you deslgned an dlagram for a company
daLabase WrlLe SCL sLaLemenLs Lo creaLe Lhe correspondlng relaLlons and capLure as many of
Lhe consLralnLs as posslble

Steps
4 lrsL begln wlLh Lhe enLlLles #mployees" and #eparLmenLs
4 @ranslaLlng Lhese Lo SCL ls sLralghLforward
4 -exL we LranslaLe Lhe relaLlonshlps Manages and ependenLs
4 We LranslaLe each Lhese Lo a Lable mapplng one enLlLy Lo anoLher
4 We also use forelgn consLralnLs Lo make sure every row ln Lhe relaLlonshlp Lables refers
only Lo rows LhaL exlsL ln Lhe enLlLy Lables
4 Slnce each deparLmenL can have aL mosL one manager each dno can appear aL mosL
once ln Lhe Manages Lable maklng lL a key for Manages
4 -oLe LhaL lf we had made (ssn dno) Lhe key for Manages a deparLmenL could have
more Lhan one Manager
4 lnally we LranslaLe Lhe weak enLlLy #hlld" and lLs correspondlng relaLlonshlp
#ependenL"

O eflne Lhe epL relaLlon ln SCL so LhaL every deparLmenL ls guaranLeed Lo have a manager

4 WrlLe an SCL sLaLemenL Lo add !ohn oe as an employee wlLh elJ 101 oqe J2 and soloty
15 000

3 WrlLe an SCL sLaLemenL Lo glve every employee a 10 percenL ralse

6 WrlLe an SCL sLaLemenL Lo deleLe Lhe @oy deparLmenL Clven Lhe referenLlal lnLegrlLy
consLralnLs you chose for Lhls schema explaln whaL happens when Lhls sLaLemenL ls execuLed
7 WhaL oLher acLlons can Lhe sysLem Lake on deleLlng a epL Luple? WhaL are Lhe pros and cons of
each acLlon?
1 Cn deleLe seL null
2 Cn deleLe seL defaulL
3 Cn deleLe cascade



rob|em 3
O eslgn a schema LhaL capLures all Lhe lnformaLlon LhaL gallerles need Lo malnLaln
O Callerles keep lnformaLlon abouL arLlsLs Lhelr names (whlch are unlque) blrLhplaces ageand sLyle
of arL or each plece of arLwork Lhe arLlsL Lhe year lL was made lLs unlque LlLle lLs Lype of arL (eg
palnLlng llLhograph sculpLure phoLograph) and lLs prlce musL be sLored leces of arLwork are also
classlfled lnLo groups of varlous klnds for example porLralLs sLlll llfe's works by lcasso or works of
Lhe 19Lh cenLury a glven plece may belong Lo more Lhan one group
O ach group ls ldenLlfled by a name (llke Lhose [usL glven) LhaL descrlbes Lhe group lnally gallerles
keep lnformaLlon abouL cusLomers or each cusLomer gallerles keep LhaL person's unlque name
address LoLal amounL of dollars spenL ln Lhe gallery (very lmporLanL!) and Lhe arLlsLs and groups of
arL LhaL Lhe cusLomer Lends Lo llke
O raw Lhe dlagram for Lhe daLabase

Assumpt|ons
#arLlsLs Lhelr names (whlch are unlque) blrLhplaces age and sLyle of arL"
#or each plece of arLwork Lhe arLlsL Lhe year lL was made lLs unlque LlLle lLs Lype of arL and
lLs prlce musL be sLored"
#arLlsLs Lhelr names (whlch are unlque) blrLhplaces age and sLyle of arL"
#or each plece of arLwork Lhe arLlsL Lhe year lL was made lLs unlque LlLle lLs Lype of arL and
lLs prlce musL be sLored"
AlLhough noL expllclLly menLloned ln Lhe problem we assume LhaL each plece of arLwork had Lo
be palnLed by an arLlsL
We also assume LhaL each plece of arLwork was creaLed by exacLly one arLlsL


rob|em 4
O WrlLe SCL sLaLemenLs Lo creaLe Lhe correspondlng relaLlons Lo Lhe dlagram you deslgned
above lf your LranslaLlon cannoL capLure any consLralnLs ln Lhe dlagram explaln why
O Clve an example of a forelgn key consLralnL LhaL lnvolves Lhe epL relaLlon WhaL are Lhe
opLlons for enforclng Lhls consLralnL when a user aLLempLs Lo deleLe a epL Luple?






rob|em S
oo ote tepolteJ to cteote o cooceptool Joto moJel of tbe Joto tepoltemeots fot o compooy tbot
speclollzes lo l1 ttololoq 1be compooy bos J0 losttoctots ooJ coo booJle op to 100 ttoloees pet
ttololoq sessloo 1be compooy offets flve oJvooceJ tecbooloqy cootses eocb of wblcb ls tooqbt
by o teocbloq teom of two ot mote losttoctots ocb losttoctot ls osslqoeJ to o moxlmom of two
teocbloq teoms ot moy be osslqoeJ to Jo teseotcb ocb ttoloee ooJettokes ooe oJvooceJ
tecbooloqy cootse pet ttololoq sessloo
(o) lJeotlfy tbe molo eotlty types fot tbe compooy
(b) lJeotlfy tbe molo telotloosblp types ooJ speclfy tbe moltlpllclty fot eocb telotloosblp
5tote ooy ossomptloos yoo moke oboot tbe Joto
(c) usloq yoot ooswets fot (o) ooJ (b) Jtow o sloqle k Jloqtom to tepteseot tbe Joto
tepoltemeots fot tbe compooy


















Research

nstructor
0..*
Assigned
1..1

Advanced
1..1
Teaches
1..*

Training
1..*
Provides
1..1

TeachingTea
1..1
sPartOf
0..2

Trainee
1..*
Attends
1..*

You might also like