chapter 3 erd
TRANSCRIPT
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 1/37
Chapter 3
Data Modeling Using theEntity-Relationship (ER) Model
Copyright © 2004 Pearson Education, Inc.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 2/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-2
Chapter Outline
Example Database pplication !C"#P$%&E' #odel Concepts
( Entities and ttributes
( Entity )ypes, *alue +ets, and ey ttributes
( 'elationships and 'elationship )ypes ( -ea Entity )ypes
( 'oles and ttributes in 'elationship )ypes
E' Diagrams / $otation
E' Diagram or C"#P$% +chema
lternati1e $otations ( #3 class diagrams, others
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 3/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-3
E$ample C%M&'N
Data"ase
'euirements o the Company !o1ersimpliied or
illustrati1e purposes&
( )he company is organi5ed into DEP')#E$)s.Each department has a name, number and an
employee 6ho manages the department. -e eep
trac o the start date o the department manager.
( Each department controls a number o P'"7EC)s.Each pro8ect has a name, number and is located at a
single location.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 4/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-4
E$ample C%M&'N Data"ase
(Cont)
( -e store each E#P3"%EE9s social security number,
address, salary, sex, and birthdate. Each employee
works for one department but may work on se1eral
pro8ects. -e eep trac o the number o hours per
6ee that an employee currently 6ors on each pro8ect.
-e also eep trac o the direct supervisor o each
employee.
( Each employee may have a number o DEPE$DE$)s.:or each dependent, 6e eep trac o their name, sex,
birthdate, and relationship to employee.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 5/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-5
ER Model Concepts
Entities and ttributes ( Entities are speciic ob8ects or things in the mini/6orld that are
represented in the database. :or example the E#P3"%EE 7ohn+mith, the 'esearch DEP')#E$), the Product; P'"7EC)
( ttributes are properties used to describe an entity. :or example an
E#P3"%EE entity may ha1e a $ame, ++$, ddress, +ex,<irthDate
( speciic entity 6ill ha1e a 1alue or each o its attributes. :orexample a speciic employee entity may ha1e $ame=>7ohn +mith>,++$=>?2@4AB>, ddress =>@?, :ondren, Fouston, );>, +ex=>#>,<irthDate=>0/7$/AAG
( Each attribute has a value set !or data type& associated 6ith it ( e.g.integer, string, subrange, enumerated type, H
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 6/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-6
Types of Attributes (1)
+imple ( Each entity has a single atomic 1alue or the attribute. :or example,
++$ or +ex.
Composite ( )he attribute may be composed o se1eral components. :or example,
ddress !pt, Fouse, +treet, City, +tate, JipCode, Country& or $ame !:irst$ame, #iddle$ame, 3ast$ame&. Composition may orma hierarchy 6here some components are themsel1es composite.
#ulti/1alued ( n entity may ha1e multiple 1alues or that attribute. :or example,
Color o a C' or Pre1iousDegrees o a +)DE$). Denoted asKColorL or KPre1iousDegreesL.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 7/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-7
Types of Attributes (2)
In general, composite and multi/1alued attributes may benested arbitrarily to any number o le1els although this is
rare. :or example, Pre1iousDegrees o a +)DE$) is a
composite multi/1alued attribute denoted by
KPre1iousDegrees !College, %ear, Degree, :ield&L.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 8/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-8
Entity Types and Key Attributes
Entities 6ith the same basic attributes are grouped or typed into anentity type. :or example, the E#P3"%EE entity type or theP'"7EC) entity type.
n attribute o an entity type or 6hich each entity must ha1e auniue 1alue is called a ey attribute o the entity type. :orexample, ++$ o E#P3"%EE.
ey attribute may be composite. :or example, *ehicle)ag$umberis a ey o the C' entity type 6ith components !$umber, +tate&.
n entity type may ha1e more than one ey. :or example, the C'entity type may ha1e t6o eysM
( *ehicleIdentiication$umber !popularly called *I$& and ( *ehicle)ag$umber !$umber, +tate&, also no6n as licenseNplate number.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 9/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-9
EN*+* #E* orresponding to the
EN*+* *&E C'R
car 1!!<C ?2@, )E;+&, )B2, :ord #ustang, con1ertible, ?, !red, blac&&
car 2!!<C ?2@, $E- %"'&, -P2, $issan @00J;, 2/door, 2002, !blue&&
car @!!*+% 20, )E;+&, )D2, <uic 3e+abre, 4/door, 200@, !6hite, blue&&
.
.
.
C'
'egistration!'egistration$umber, +tate&, *ehicleID, #ae, #odel, %ear, !Color&
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 10/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-10
#UMM'R %F ER-D+'R'M
N%*'*+%N F%R ER #C.EM'##eaning
E$)I)% )%PE
-E E$)I)% )%PE
'E3)I"$+FIP )%PE
IDE$)I:%I$O 'E3)I"$+FIP )%PE
))'I<)E
E% ))'I<)E
#3)I*3ED ))'I<)E
C"#P"+I)E ))'I<)E
DE'I*ED ))'I<)E
)")3 P')ICIP)I"$ ": E2 I$ '
C'DI$3I)% ')I" ?M$ :"' E?ME2 I$ '
+)'C)'3 C"$+)'I$) !min, max& "$ P')ICIP)I"$
": E I$ '
+ymbol
E? ' E2
E? ' E2
' !min,max&
E
$
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 11/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-11
ER D+'R'M Entity *ypes are0EM&1%EE, DE&'R*MEN*, &R%2EC*, DE&ENDEN*
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 12/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-12
Relationships and Relationship
Types (1) relationship relates t6o or more distinct entities 6ith a
speciic meaning. :or example, E#P3"%EE 7ohn +mith 6orson the Product; P'"7EC) or E#P3"%EE :ranlin -ongmanages the 'esearch DEP')#E$).
'elationships o the same type are grouped or typed into a
relationship type. :or example, the -"'+N"$ relationshiptype in 6hich E#P3"%EEs and P'"7EC)s participate, or the#$OE+ relationship type in 6hich E#P3"%EEs andDEP')#E$)s participate.
)he degree o a relationship type is the number o participatingentity types. <oth #$OE+ and -"'+N"$ are binaryrelationships.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 13/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-13
E$ample relationship instanes o! the %R4#5F%R
relationship "et6een EM&1%EE and DE&'R*MEN*
e?
e2
e@
e4
eA
eB
e
E#P3"%EE
r ?
r 2
r @
r 4
r A
r B
r
-"'+N:"'
d?
d2
d@
DEP')#E$)
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 14/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-14
E$ample relationship instanes o! the %R4#5%N
relationship "et6een EM&1%EE and &R%2EC*
e?
e2
e@
e4
eA
eB
e
r ?
r 2
r @
r 4
r A
r B
r
p?
p2
p@
r
r
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 15/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-15
Relationships and Relationship
Types (2)#ore than one relationship type can exist 6ith the same
participating entity types. :or example, #$OE+ and
-"'+N:"' are distinct relationships bet6een
E#P3"%EE and DEP')#E$), but 6ith dierent
meanings and dierent relationship instances.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 16/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-16
ER D+'R'M Relationship *ypes are0%R4#5F%R, M'N'E#, %R4#5%N, C%N*R%1#,
#U&ER7+#+%N, DE&ENDEN*#5%F
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 17/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-17
Wea Entity Typesn entity that does not ha1e a ey attribute
6ea entity must participate in an identiying relationship type 6ith ano6ner or identiying entity type
Entities are identiied by the combination oM
( partial ey o the 6ea entity type
( )he particular entity they are related to in the identiying entity
typeExample:
+uppose that a DEPE$DE$) entity is identiied by the dependent9s irstname and birhtdate, and the speciic E#P3"%EE that the dependent isrelated to. DEPE$DE$) is a 6ea entity type 6ith E#P3"%EE as its
identiying entity type 1ia the identiying relationship typeDEPE$DE$)N":
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 18/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-18
ea8 Entity *ype is0 DE&ENDEN*
+denti!ying Relationship is0 DE&ENDEN*#5%F
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 19/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-19
Constraints on Relationships
Constraints on 'elationship )ypes
( ! lso no6n as ratio constraints &
( #aximum Cardinality "ne/to/one !?M?&
"ne/to/many !?M$& or #any/to/one !$M?&
#any/to/many
( #inimum Cardinality !also called participationconstraint or existence dependency constraints& 5ero !optional participation, not existence/dependent&
one or more !mandatory, existence/dependent&
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 20/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-20
Many-to-one (N09) RE1'*+%N#.+&
e?
e2
e@
e4
eA
eB
e
E#P3"%EE
r ?
r 2
r @
r 4
r A
r B
r
-"'+N:"'
d?
d2
d@
DEP')#E$)
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 21/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-21
Many-to-many (M0N) RE1'*+%N#.+&
e?
e2
e@
e4
eA
eB
e
r ?
r 2
r @
r 4
r A
r B
r
p?
p2
p@
r
r
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 22/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-22
Relationships and Relationship
Types (!)
-e can also ha1e a recursive relationship type.<oth participations are same entity type in dierent roles.
:or example, +PE'*I+I"$ relationships bet6een
E#P3"%EE !in role o super1isor or boss& and !another&
E#P3"%EE !in role o subordinate or 6orer&. In ollo6ing igure, irst role participation labeled 6ith ? and
second role participation labeled 6ith 2.
In E' diagram, need to display role names to distinguish
participations.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 23/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-23
' RECUR#+7E RE1'*+%N#.+&
#U&ER7+#+%N
e?
e2
e@
e4
eA
eB
e
E#P3"%EE
r ?
r 2
r @
r 4
r A
r B
+PE'*I+I"$
2?
?2
2
?
?
?2
?
2
2
© )he <en8aminCummings Publishing Company, Inc. ?4, Elmasri$a1athe, :undamentals o Database +ystems, +econd Edition
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 24/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-24
Rersive Relationship *ype is0 #U&ER7+#+%N
(partiipation role names are sho6n)
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 25/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-25
Attributes of Relationship types
relationship type can ha1e attributesQ or
example, FoursPer-ee o -"'+N"$Q its
1alue or each relationship instance describes
the number o hours per 6ee that an
E#P3"%EE 6ors on a P'"7EC).
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 26/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-26
'ttri"te o! a Relationship *ype is0.ors o! %R4#5%N
#t t l C t i t
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 27/37Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-27
#trtral Constraints
one 6ay to e$press semantis
o! relationshipsStructural costraits o relatioships:
Car!ialit" ratio !o a binary relationship&M ?M?, ?M$, $M?,or #M$
S#$%& '( )*+C,& +)).$).,+/E &'E. $& /#E*,&
)articipatio costrait !on each participating entitytype&M total !called existence dependency& or partial.
S#$%& '( $'*E *,&,& /#E *,&
$")EM )hese are easy to speciy or <inary 'elationship)ypes.
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 28/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-28
'lternative (min, ma$) notation !or relationship
strtral onstraints0 +peciied on each participation o an entity type E in a relationship type '
+peciies that each entity e in E participates in at least min and at most maxrelationship instances in '
Deault!no constraint&M min=0, max=n
#ust ha1e min≤max, min≥0, max ≥?
Deri1ed rom the no6ledge o mini/6orld constraints
ExamplesM
department has exactly one manager and an employee can manage at most
one department.
( +peciy !0,?& or participation o E#P3"%EE in #$OE+
( +peciy !?,?& or participation o DEP')#E$) in #$OE+ n employee can 6or or exactly one department but a department can ha1e
any number of employees.
( +peciy !?,?& or participation o E#P3"%EE in -"'+N:"'
( +peciy !0,n& or participation o DEP')#E$) in -"'+N:"'
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 29/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-29
The ("in#"a$) notation
relationship constraints
!?,?&!0,?&
!?,$&!?,?&
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 30/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-30
C"#P$% E' +chema Diagram
using !min, max& notation
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 31/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-31
Relationships o! .igher Degree
'elationship types o degree 2 are called iar"
'elationship types o degree @ are called terar" and odegree n are called -ar"
In general, an n/ary relationship is not eui1alent to n
binary relationships
Figher/order relationships discussed urther in Chapter 4
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 32/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-32
Data Modeling *ools
number o popular tools that co1er conceptual
modeling and mapping into relational schema
design. ExamplesM E'-in, +/ Designer!Enterprise pplication +uite&, E'/ +tudio, etc.
P"+I)I*E+M ser1es as documentation o
application reuirements, easy user
interace / mostly graphics editor support
& "l ith C t
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 33/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-33
&ro"lems 6ith Crrent
Modeling *oolsDIO'##I$O
( Poor conceptual meaningul notation.
( )o a1oid the problem o layout algorithms and aesthetics
o diagrams, they preer boxes and lines and do nothing
more than represent !primary/oreign ey& relationships
among resulting tables.!a e6 exceptions&
#E)F"D"3O%
( lac o built/in methodology support. ( poor tradeo analysis or user/dri1en design preerences.
( poor design 1eriication and suggestions or impro1ement.
Some o the Curretl" +vailale +utomate! ataase
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 34/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-34
Some o the Curretl" +vailale +utomate! ataase
esi /ools
C$)+&( /$$* &C/,$&+*,/(
Emarca!ero
/echoloies
E. Stu!io ataase o!eli i E. a! ,E1
' +rtisa ataase a!miistratio a! space a! securit"maaemet
$racle eveloper 2000 a!
esier 2000
ataase mo!eli applicatio !evelopmet
)op;i Sot<are S"stem +rchitect 2001 ata mo!eli o=ect mo!eli process mo!elistructure! aal"sis>!esi
)latium/echolo"
)latium Eterpriceo!eli Suite: Er<i')%i )ara!im )lus
ata process a! usiess compoet mo!eli
)ersistece ,c )<ertier appi rom $-$ to relatioal mo!el
.atioal .atioal .ose o!eli i * a! applicatio eeratio i C??
a! @+A+
.oue %are .% etro appi rom $-$ to relatioal mo!el
.esolutio *t! case Coceptual mo!eli up to co!e maiteace
S"ase Eterprise +pplicatio Suite ata mo!eli usiess loic mo!eli
Aisio Aisio Eterprise ata mo!eli !esi a! reeieeri Aisual 'asica! Aisual C??
ER D+'R'M F%R ' :'N4
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 35/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-35
ER D+'R'M F%R ' :'N4
D'*':'#E
© )he <en8aminCummings Publishing Company, Inc. ?4, Elmasri$a1athe, :undamentals o Database +ystems, +econd Edition
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 36/37
Copyright © 2004 Pearson Education, Inc.
Elmasri/Navathe, Fndamentals o! Data"ase #ystems, Forth Edition Chapter 3-36
&R%:1EM 6ith ER notation
)FE E$)I)% 'E3)I"$+FIP #"DE3 I$
I)+ "'IOI$3 :"'# DID $")+PP"') )FE +PECI3IJ)I"$
OE$E'3IJ)I"$ <+)'C)I"$+
E t d d E tit R l ti hi
7/23/2019 Chapter 3 ERD
http://slidepdf.com/reader/full/chapter-3-erd 37/37
El i/N th F d t l ! D t " # t F th Editi Ch t 3 37
E$tended Entity%Relationship
(EER) Model
Incorporates +et/subset relationships
Incorporates +peciali5ationOenerali5ation Fierarchies
$E;) CFP)E' I33+)')E+ F"- )FE E'
#"DE3 C$ <E E;)E$DED -I)F
/ +et/subset relationships and
+peciali5ationOenerali5ation Fierarchies and ho6 todisplay them in EE' diagrams