Modul E-2 Ent I T Y - Rel at I Onshi Pmodel

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Modul

e-2
Ent
it
y-Rel
ati
onshi
pModel
Usi
ngHi
gh-
Lev
elConcept
ual
Dat
aModel
sforDat
abaseDesi
gn

Themai
nphasesi
nvol
vedi
nthedesi
gnofdat
abasei
sasshownbel
ow:

Fi
gur
eshowsasi
mpl
i
fiedov
erv
iewoft
hedat
abasedesi
gnpr
ocess

Thef irststepisrequirement scoll


ecti
onandanal ysis.Dur
ingthi
sst ep,
thedatabase
designer sinter
viewpr ospecti
vedatabaseuserstounder standanddocumentt hei
r
datar equirement s.Theresultofthi
sst episaconciselywrit
tensetofusers’
requirement s.
(Theser equirement sshouldbespeci f
iedindetai
l
)andf uncti
onalrequi
rementsofthe
application.(Theseconsi stoftheuserdefi
nedoperations)

Thenextst epist ocreat


eaconcept ualschemaf orthedatabase,
usingahigh-l
evel
conceptualdatamodel .Thi
sstepiscalledconceptualdesi
gn.Theconceptualschema
i
saconci sedescr i
ptionoft
hedat arequir
ementsoft heusersandincl
udesdetail
ed
descri
pti
onsoft heent i
ty
ty
pes,relat
ionships,andconstr
aints;t
heseareexpressedusingtheconceptsprovi
ded
bythehigh-l
eveldatamodel .Becausetheseconceptsdonoti ncl
udeimplementati
on

Page1
detai
ls,t
heyar eusuall
yeasi
ertounderst
andandcanbeusedtocommuni cat
ewith
nontechni
cal user
s
.
Thenextst epindatabasedesi
gnistheactuali
mplement
ati
onofthedat
abase,usi
ng
acommer cialDBMS.Thisst
episcal
ledlogi
caldesi
gnordatamodelmapping;i
ts
resul
tisadat abaseschemaintheimplementat
iondat
amodeloftheDBMS

Thelaststepisthephy si
caldesignphase,duri
ngwhichtheint
ernal
storagestr
uctur
es,
fi
leorganizat
ions,
indexes,accesspaths,andphysi
caldesi
gnparametersfor
thedatabasef i
l
esarespecifi
ed.Inparall
elwit
htheseacti
vi
ti
es,appl
icat
ionprograms
aredesignedandimpl emented.

Ent
it
yTy
pes,
Ent
it
ySet
s,At
tri
but
es,
andKey
s

Ent
it
iesandAt
tri
but
es

Ent
it
iesar
ethebasicobjectofanERmodel.I
trepr
esentsathi
ngintherealworl
dwi
th
ani
ndependentexi
stence.exampl
e,apar
ti
cul
arperson,
car,
house,oremployee

Att
ri
but esthepart
icularpr
oper
ti
esthatdescr
ibethepar
ti
cul
arEnti
ty
Forexampl e,anEMPLOYEEent it
ymaybedescr i
bedbytheemployee’
sname,
age,
address,sal
ary,
andj ob.

Ty
pesofAt
tri
but
es

1.Composi t
ev er
susSimple(Atomi c)Att
ri
butes.
2.Single-
ValuedversusMult
ivaluedAt t
ri
butes.
3.StoredversusDerivedAt
tri
but es.

Composi t
eattr
ibutescanbedi vi
dedintosmal l
ersubpart
s,whichrepresentmor ebasi
c
att
ri
butesForexampl e,theAddressattr
ibuteoftheEMPLOYEEent i
tycanbe
subdi
videdint
oSt r
eet_address,
City
,State,andZip.At
tri
butesthatarenotdivi
sibleare
cal
ledsimpleoratomicat t
ribut
es.Forexampl eRegno,Age,DOB,Sexet c.
.

Si
ngl
e-Valuedver
susMul
ti
valuedAt
tri
butes.
Mostattr
ibut
eshaveasi
ngl
ev al
uef
orapar t
icul
arent
ity
;suchat
tr
ibutesarecal
l
ed
si
ngl
e-val
ued.Forexampl
e,Ageisasingl
e-v
aluedatt
ri
buteofaperson.I
nsomecases

Page2
anatt
ri
but
ecanhaveasetofv
aluesf
ort
hesameentit
yForexampl
ethephonenoofa
per
sonsuchat
tri
but
esar
ecall
edasmult
ival
uedat
tri
butes.

Storedv ersusDer i
vedAt tr
ibut
es.
I
nsomecases, t
hev al
ueofoneat t
ri
butecanbeobt ai
nedusingthev al
ueofanother
att
ribute.Forexample, ageofaper soncanbeobt ai
nedfrom thedateofbirt
hofthe
personsuchat tr
ibut
esar ecall
edasder iv
edat t
ri
butes.
Suchat t
ri
butesthatcannotbe
obtainedusi ngthevalueofanot heratt
ri
buteiscall
edasstoredattr
ibut
e.Forexample
thedat eofbi r
thattr
ibuteisthestoredatt
ribut
e.

NULLValues.Insomecases, aparti
cul
arenti
tymaynothaveanappl
icabl
ev al
ue
foranat
tri
buteForexample,Col
lege_degr
eesattr
ibut
eappl
iesonl
ytopeoplewith
coll
egedegrees.Forsuchsi
tuat
ions,aspeci
alval
uecall
edNULLiscreat
ed.

ComplexAt t
ri
butes:
AnAttri
but
eswhichisbothcompositeandmulti
val
uediscal
ledascompl
exAttr
ibut
e.
Forexample,
apersoncanhav emorethanonephonenumbersandeachphone
numbershascountrycode,
statecode,
fol
lowedbythenumbers.

Ent
it
yTy
pes,
Ent
it
ySet
s,Key
s,andVal
ueSet
s

AnEnti
tytypedef
inesacoll
ecti
on(orset)ofent
it
iest
hathav
ethesameattr
ibut
es.
EachEnti
tytypei
nthedatabaseisdescri
bedbyit
snameandattr
ibut
es.Anenti
tyt
ype
i
salsocall
edasthe“Schema”or“ I
ntensi
on”
.

Thecol
lect
ionofal
lent
it
iesofaparti
cul
arent
it
yty
peinthedatabaseatanypoi
nti
n
ti
meiscall
edanenti
tyset.Anent
it
ysetisal
socal
ledastheextensi
on.

KeyAt
tri
but
esofanEnt
it
yTy
pe.

Animportantconstr
aintontheenti
ti
esofanentit
ytypei
sthekeyoruni
queness
const
rai
ntonat tri
butes.Anenti
tyty
peusuall
yhasoneormoreat t
ri
but
eswhoseval
ues
aredi
sti
nctforeachindivi
dualent
it
yintheent
ityset
.Suchanatt
ri
butei
scall
edakey

Page3
att
ri
bute,
andit
sval
uescanbeusedtoident
if
yeachent
it
yuni
quel
y.
Forex,
Theper
son
enti
tyt
ypehasakeyat
tri
but
ecal
ledSsn.

Rel
ati
onshi
pTy
pes,
Set
s,andI
nst
ances

Arel
ati
onshi
ptypeRamongnenti
tytypesE1,E2,.
..En def
, inesasetofassoci
ati
ons
amongenti
ti
es.I
trel
atest
woormoredist
inctent
it
ieswi
thaspecif
icmeaning,

ARelat
ionshi
pSetsRisacoll
ect
ionofsimil
arrelati
onshi
ps(
or)arel
ati
onshi
psetRi
s
asetofrel
ati
onal
inst
ancesr
iwhereeachriassociat
esnindi
vi
dual
enti
ti
es.

Degr
eeofaRelat
ionshipty
pes
Degr
eeofar
elati
onshipty
peisthenumberofpar
ti
cipat
ingent
it
yty
pes.

Bi
nar
yRelati
onshi
p:
I
ftwoent
it
iesarei
nvol
vedi
nar
elat
ionshi
p,
theni
tiscal
l
edasbi
nar
yrel
ati
onshi
p.

Ternar
yRelati
onshi
p:
I
fthreeent
it
iesarei
nvol
vedt
heni
tiscal
l
edast
ernar
yrel
ati
onshi
p.

Page4
Recur si
veRel ationshi
p:Thesameentit
yty pepar
ti
cipat
esmor ethanoncei
na
relat
ionshipt y
pei ndif
fer
entrol
es.
InsuchcasesRoleNamebecomesessent i
alf
or
disti
nguishingt hemeaningofeachparti
cipati
on,
suchrelat
ionshi
ptypesar
ecall
edas
recursiv
er elat
ions.

TheSUPERVI SIONr elationshi


pt yperelatesanempl oyeetoasuper visor,whereboth
employeeandsuper visorenti
ti
esar emember soft hesameEMPLOYEEent it
yset.
Hence,theEMPLOYEEent i
tytypepar ti
cipatestwi ceinSUPERVI SION: oncei ntherol
eof
supervi
sor( orboss) ,andoncei nt heroleofsuper vi
see( orsubordi
nat e).Each
rel
ati
onshipi nstancer iinSUPERVI SIONassoci atest woempl oyeeent i
tiesejandek,one
ofwhichpl ayst heroleofsuper vi
sorandt heot herther oleofsupervisee.InFigure,t
he
l
inesmar ked‘ 1’representthesuper visorrole,andt hosemar ked‘2’ r
epresentt he
supervi
seer ole;hence, e1super v
isese2ande3, e4super vsese6ande7,
i ande5
supervsese1ande4.I
i nthisexampl e,eachr el
ationshipinstancemustbeconnect ed
witht
wol ines, onemar kedwith‘1’ (
super vi
sor)andt heotherwith‘2’(supervi
see).

Const
rai
ntsonBi
nar
yRel
ati
onshi
pTy
pes

Relat
ionshiptypesusuall
yhavecer t
ainconstrai
ntsthatl
imitthepossiblecombinati
ons
ofentiti
esthatmaypartici
patei
nt hecorrespondingrel
ati
onshipset.Binaryrel
ati
onshi
p
constrai
ntscanbedi st
ingui
shedintotwot ypes:cardi
nal
ityrati
oandpar ti
cipat
ion.

Thecar dinali
tyrati
of orabinar
yrelat
ionshi
pspecifi
esthemaximum numberof
relat
ionshipinstancesthatanentit
ycanpar t
ici
patein.Thepossi
blecar
dinal
i
tyr
ati
osf
or
binaryrel
ationshiptypesare1:1,1:
N,N:1,andM: N.

Anexampleofa1:1binar
yrel
ati
onshipisMANAGES,whi
chrel
atesadepartmentent
it
y
totheempl
oyeewhomanagest hatdepart
ment
.Thi
srepr
esent
st heconstr
aint
s
that
—atanypoi
ntinti
me—anempl oyeecanmanageonedepar
tmentonlyanda
depart
mentcanhaveonemanageronl y
.

Page5
Therel
ati
onshi
pty
peWORKS_ON i
sofcar
dinal
it
yrati
oM:N,becauset
hemini
-worl
d
rul
eist
hatanemploy
eecanwor
konsever
alproj
ectsandaproj
ectcanhav
esever
al
employ
ees.

Par t
ici
pat i
onConst r aints:
Thepar ti
cipati
onconst rai
ntspecifieswhethert heexist
enceofanentitydependsonit
s
beingrelatedtoanot herentityviatherelat
ionshipt y
pe.Thisconst
rai
ntspecifi
esthe
mi ni
mum numberofr elati
onshipinstancesthateachent it
ycanparti
cipatei
n,andis
somet i
mescal l
edt hemi ni
mum car di
nalit
yconst rai
nt.
Ther earet woty pesofpar t
icipati
onconst r
aintsnamel y
:
(1)Totalparti
ci
pat ion( Exi
stenceDependency )
(2)Partialpart
icipat i
on.

Forexampl e.Ifacompanypol icystatesthatev eryempl oyeemustwor kf ora


depart
ment, t
henanempl oyeeent i
tycanexi stonlyifitpart
icipat
esinatl eastone
WORKS_ FORr elati
onship
i
nstance.Thus, theparti
cipati
onofEMPLOYEEi nWORKS_ FORi scall
edt ot al
part
ici
pati
on, (meaningthatev eryent i
t nt
yi hetot alsetofempl oyeeentit
iesmustbe
rel
atedtoadepar tmentent i
tyviaWORKS_ FOR.)Tot alparti
cipati
onisalsocal led
exi
stencedependency
Forexample,wedonotexpectev eryemploy eetomanageadepar t
ment ,sot he
part
ici
pati
onofEMPLOYEEi ntheMANAGESr elationshi
pt y
pei sparti
al.Tot al
part
ici
pati
oni srepresent
edbydoubl eli
nesinanERdi agram.Parti
alparti
ci pati
onis

Page6
r
epr
esent
edbysi
ngl
eli
nei
nanERdi
agr
am.

NOTE:
Thecardi
nali
tyr
ati
oandparti
cipat
ionconst
rai
nts,
toget
herf
orm,
ast
he
str
uct
uralconst
rai
ntsofr
elat
ionshipt
ype.

WeakEnti
ty
Ent
it
ytypesthatdonothavekeyat
tri
but
esofthei
rownarecal
l
edweakent
it
y
t
ypes.I
ncontr
ast,t
hest r
ongenti
ti
esaresuchent
it
ieswhichhav
eakeyoft
hei
rown.

Weakentit
yisidentif
iedthroughanot
herstr
ongenti
tyi
ncombinationwi
thoneofit
s
att
ri
butesuchstrongentityiscal
l
edastheident
if
yingorownerentit
yty
pe.The
rel
ati
onshi
ptypet hatrel
atesaweakentit
ytypet
oitsowneri
scalledasthe“i
dent
if
ying
rel
ati
onshi
p”.

Aweakentit
ynormal
lyhasa“ par
ti
alkey”whi
chisanatt
ri
butethatuniquel
yidenti
fy
weakenti
ti
es.
InERdiagr
amsbot haweakentit
ytypeandit
sidenti
fyi
ngr el
ati
onshi
pare
di
sti
ngui
shedbysurr
oundingthei
rboxesanddiamondswit
hdoublelines,Furt
herthe
par
ti
alkeyatt
ri
but
eisunderl
inedwit
hadashedl i
ne.

ERDi
agr
ams,
Nami
ngConv
ent
ions,
andDesi
gnI
ssues

Page7
Enti
ti
esarerepresentedinrect
angul
arboxes.Relati
onshipt
ypesar eshownin
diamond-shapedboxesattachedtothepart
ici
patingenti
tytypeswi
thst
raight
l
ines.Att
ri
butesar
eshowni nov al
s,andeachattr
ibuteisatt
achedbyastraightl
i
netoi
ts
enti
tytypeorrel
ati
onshiptype.

Componentat
tri
but
esofacomposi
teat
tr
ibut
ear
eat
tachedt
otheov
al
r
epr
esent
ingt
hecomposi
teat
tri
but
e.Mul
ti
val
uedat
tr
ibut
esar
eshowni
ndoubl
eov
als.
Keyat
tri
but
eshav
ethei
rnamesunder
li
ned.Der
ivedat
tr
ibut
esar
eshowni
ndot
tedov
als.
Weakent
it
yty
pesar
edi
sti
ngui
shedbybei
ngpl
acedi
ndoubl
erect
angl
esandbyhav
ing
t
hei
rident
if
yingr
elat
ionshi
ppl
acedi
ndoubl
edi
amonds,
Thepar
ti
alkeyoft
heweak
ent
it
yty
pei
sunder
li
nedwi
thadot
tedl
i
ne.
Whendesi
gni
ngadat
abaseschema,
thechoi
ceofnamesf
orent
it
yty
pes,
at
tr
ibut
es,
rel
ati
onshi
pty
pes,
andr
olesi
sar
enotal
way
sst
rai
ght
for
war
d.Oneshoul
d
choosenamest
hatconv
ey,
asmuchaspossi
ble,
themeani
ngsat
tachedt
othedi
ff
erent

Page8
const
ruct
sint
heERschema.
Usual
l
ysi
ngul
arnamesf
orent
it
yty
pes,
rat
hert
hanpl
ural
ones,
becauset
heent
it
yty
pe
nameappl
i
est
oeachi
ndi
vi
dual
ent
it
ybel
ongi
ngt
othatent
it
yty
pe
Theent
it
iesandr
elat
ionshi
pty
penamesar
eupper
casel
ett
ers,
att
ri
but
enames
hav
ethei
rini
ti
all
ett
ercapi
tal
i
zed,
andr
olenamesar
elower
casel
ett
ers.
Asagener
al
pr
act
ice,
giv
enanar
rat
ivedescr
ipt
ionoft
hedat
abaser
equi
rement
s,henouns
t
appear
ingi
nthenar
rat
ivet
endt
ogi
ver
iset
oent
it
yty
penames, hev
andt erbst
endt
o
i
ndi
cat
enamesofr
elat
ionshi
pty
pes.
Anot
hernami
ngconsi
der
ati
oni
nvol
veschoosi
ng
bi
nar
yrel
ati
onshi
pnamest
omaket
heERdi
agr
am oft
heschemar
eadabl
efr
om l
eftt
o
r
ightandf
rom t
opt
obot
tom.

ERDiagr
ams: TheCOMPANYdat abaseschemausi
ngthe(
min,max)not
ati
on.Usual
l
y,
oneusesei
therthecar
dinal
i
tyr
atio/
singl
e-l
i
ne/
doubl
e-l
i
nenot
atonort
i he(min,max)
not
ati
on.

Page9
Page10
Page11

You might also like