the enhanced er model and business rules
TRANSCRIPT
-
7/21/2019 The Enhanced ER Model and Business Rules
1/23
2007 by Prentice Hall 2007 by Prentice Hall 11
Chapter 4:Chapter 4:The Enhanced ER ModelThe Enhanced ER Model
and Business Rulesand Business Rules
Modern DatabaseModern Database
ManagementManagement
88thth
EditionEditionJefrey A. Hofer, Mary B. Prescott,Jefrey A. Hofer, Mary B. Prescott,
Fred R. McFaddenFred R. McFadden
-
7/21/2019 The Enhanced ER Model and Business Rules
2/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 22
ObjectivesObjectives
Defnition o termsDefnition o terms se o supert!pe"subt!pe relationshipsse o supert!pe"subt!pe relationships se o #enerali$ation and speciali$ationse o #enerali$ation and speciali$ation
techni%uestechni%ues &pecifcation o completeness and disjointness&pecifcation o completeness and disjointness
constraintsconstraints Develop supert!pe"subt!pe hierarchies orDevelop supert!pe"subt!pe hierarchies or
realistic business situationsrealistic business situations
-
7/21/2019 The Enhanced ER Model and Business Rules
3/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 33
&upert!pes and &ubt!pes&upert!pes and &ubt!pes
&ubt!pe:&ubt!pe:' sub#roupin# o the entities in an' sub#roupin# o the entities in anentit! t!pe that has attributes distinct romentit! t!pe that has attributes distinct romthose in other sub#roupin#sthose in other sub#roupin#s
&upert!pe:&upert!pe:' #eneric entit! t!pe that has a' #eneric entit! t!pe that has arelationship (ith one or more subt!pesrelationship (ith one or more subt!pes
'ttribute )nheritance:'ttribute )nheritance: &ubt!pe entities inherit values o all&ubt!pe entities inherit values o all
attributes o the supert!peattributes o the supert!pe 'n instance o a subt!pe is also an instance'n instance o a subt!pe is also an instance
o the supert!peo the supert!pe
-
7/21/2019 The Enhanced ER Model and Business Rules
4/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 44
*i#ure 4+, Basic notation or supert!pe"subt!pe notation
a- EER
notation
-
7/21/2019 The Enhanced ER Model and Business Rules
5/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 55
Di.erent modelin# tools ma! have di.erent notation or thesame modelin# constructs
b-
Microsot/isio
0otation
*i#ure 4+, Basic notation or supert!pe"subt!pe notation 1cont2-
-
7/21/2019 The Enhanced ER Model and Business Rules
6/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 66
Figure 4-2 Employee supertype it! t!ree subtypes
All employee subtypes
will have emp nbr, name,address, and date-hired
Each employee subtypewill also have its own
attributes
-
7/21/2019 The Enhanced ER Model and Business Rules
7/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 77
Relationships and &ubt!pesRelationships and &ubt!pes
Relationships at theRelationships at the suertyesuertyelevellevel
indicate that all subt!pes (illindicate that all subt!pes (ill
participate in the relationshipparticipate in the relationshipThe instances o aThe instances o a subtyesubtyema!ma!
participate in a relationship uni%ue toparticipate in a relationship uni%ue to
that subt!pe2 )n this situation3 thethat subt!pe2 )n this situation3 therelationship is sho(n at the subt!perelationship is sho(n at the subt!pe
levellevel
-
7/21/2019 The Enhanced ER Model and Business Rules
8/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall ""
Figure 4-3 #upertype$subtype relations!ips in a !ospital
Both
outpatients
and residentpatients are
cared for by
a responsible
physician
Only resident patients are
assigned to a bed
-
7/21/2019 The Enhanced ER Model and Business Rules
9/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall %%
enerali$ation andenerali$ation and
&peciali$ation&peciali$ation !enera"i#ation$!enera"i#ation$The process oThe process o
defnin# a more #eneral entit! t!pe romdefnin# a more #eneral entit! t!pe rom
a set o more speciali$ed entit! t!pes2a set o more speciali$ed entit! t!pes2BOTTOM+5BOTTOM+5
%ecia"i#ation$%ecia"i#ation$The process oThe process o
defnin# one or more subt!pes o thedefnin# one or more subt!pes o thesupert!pe and ormin# supert!pe"subt!pesupert!pe and ormin# supert!pe"subt!pe
relationships2 TO5+DO60relationships2 TO5+DO60
-
7/21/2019 The Enhanced ER Model and Business Rules
10/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1010
Figure 4-4 E&le o' generali(ation
a) *!ree entity types+ ,./ *.,/ an *.,,E
All these types of vehicles have common attributes
-
7/21/2019 The Enhanced ER Model and Business Rules
11/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1111
Figure 4-4 E&le o' generali(ation cont8)
So we put
the sharedattributes in
a supertype
ote! no subtype for motorcycle, since it has no uni"ue
attributes
b) 9enerali(ation to :EH;,E supertype
-
7/21/2019 The Enhanced ER Model and Business Rules
12/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1212
Figure 4-5 E&le o' speciali(ation
a) Entity type P.*
Onl! applies tomanuactured parts
'pplies onl! to purchased part
-
7/21/2019 The Enhanced ER Model and Business Rules
13/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1313
b) #peciali(ation to
-
7/21/2019 The Enhanced ER Model and Business Rules
14/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1414
Constraints in &upert!pe"Constraints in &upert!pe"
Completeness ConstraintCompleteness Constraint &om"eteness &onstraints&om"eteness &onstraints: 6hether: 6hether
an instance o a supert!pean instance o a supert!pe mustmustalso be aalso be amember o at least one subt!pemember o at least one subt!peTotal &peciali$ation Rule: 7es 1double line-Total &peciali$ation Rule: 7es 1double line-
5artial &peciali$ation Rule: 0o 1sin#le line-5artial &peciali$ation Rule: 0o 1sin#le line-
-
7/21/2019 The Enhanced ER Model and Business Rules
15/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1515
Figure 4-6 E&les o' completeness constraints
a) *otal speciali(ation rule
A patient must be either
an outpatient or aresident patient
-
7/21/2019 The Enhanced ER Model and Business Rules
16/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1616
b) Partial speciali(ation rule
A vehicle
could be a
car, a truc$,or neither
Figure 4-6 E&les o' completeness constraints cont8)
-
7/21/2019 The Enhanced ER Model and Business Rules
17/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1717
Constraints in &upert!pe"Constraints in &upert!pe"
Disjointness constraintDisjointness constraint Dis'ointness &onstraintsDis'ointness &onstraints: 6hether: 6hether
an instance o a supert!pe ma!an instance o a supert!pe ma!
simultaneouslysimultaneouslybe a member o t(o 1orbe a member o t(o 1ormore- subt!pesmore- subt!pes Disjoint Rule: 'n instance o the supert!peDisjoint Rule: 'n instance o the supert!pe
can be onl! O0E o the subt!pescan be onl! O0E o the subt!pes
Overlap Rule: 'n instance o the supert!peOverlap Rule: 'n instance o the supert!pe
could be more than one o the subt!pescould be more than one o the subt!pes
'
-
7/21/2019 The Enhanced ER Model and Business Rules
18/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1"1"
a) =is>oint rule
Figure 4-7 E&les o' is>ointness constraints
A patient can either be outpatient
or resident, but not both
-
7/21/2019 The Enhanced ER Model and Business Rules
19/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 1%1%
b) ?erlap rule
A part may be bothpurchased and
manufactured
Figure 4-7 E&les o' is>ointness constraints cont8)
-
7/21/2019 The Enhanced ER Model and Business Rules
20/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 2020
Constraints in &upert!pe"Constraints in &upert!pe"
&ubt!pe Discriminators&ubt!pe Discriminators %ubtye Discriminator%ubtye Discriminator: 'n attribute: 'n attribute
o the supert!pe (hose values determineo the supert!pe (hose values determine
the tar#et subt!pe1s-the tar#et subt!pe1s- DisjointDisjoint8 a8 a simplesimpleattribute (ith alternativeattribute (ith alternative
values to indicate the possible subt!pesvalues to indicate the possible subt!pes
OverlappingOverlapping8 a8 a compositecompositeattribute (hoseattribute (hose
subparts pertain to di.erent subt!pes2 Eachsubparts pertain to di.erent subt!pes2 Eachsubpart contains a boolean value to indicatesubpart contains a boolean value to indicate
(hether or not the instance belon#s to the(hether or not the instance belon#s to the
associated subt!peassociated subt!pe
di j i t
-
7/21/2019 The Enhanced ER Model and Business Rules
21/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 2121
Figure 4-" ;ntroucing a subtype iscriminator disjointrule)
A simple attribute with
different possible values
indicating the subtype
-
7/21/2019 The Enhanced ER Model and Business Rules
22/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 2222
Figure 4-% #ubtype iscriminator overlaprule)A composite
attribute with
sub-attributes
indicating %yes&or %no& to
determine
whether it is of
each subtype
-
7/21/2019 The Enhanced ER Model and Business Rules
23/23
Chapter 4 2007 by Prentice Hall 2007 by Prentice Hall 2323
Figure 4-10 E&le o' supertype$subtype !ierarc!y