21
7/21/2019 Chapter 3. Enhanced Entity Relationship http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 1/21 © Shamkant B. Navathe CC

Chapter 3. Enhanced Entity Relationship

Embed Size (px)

DESCRIPTION

Database Notes

Citation preview

Page 1: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 1/21

© Shamkant B. Navathe

CC

Page 2: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 2/21

© Shamkant B. Navathe

CC

Chapter 4 - Part I

Enhanced Entity-Relationshipand UML Modeling

Copyright © 2004 Ramez Elmasri and Shamkant Navathe.

Page 3: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 3/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Enhanced-ER (EER) Model

ConceptsInl!des all modeling onepts o" #asi ER

$dditional onepts% s!#lasses&s!perlasses'

speialization&generalization' ategories' attri#!teinheritane

(he res!lting model is alled the enhaned)ER orE*tended ER +E2R or EER, model

It is !sed to model appliations more ompletely anda!rately i" needed

It inl!des some o#-et)oriented onepts' s!h asinheritane

Page 4: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 4/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Subclasses and Superclasses (1)

$n entity type may have additional meaning"!ls!#gro!pings o" its entities

E*ample% E/1EE may #e "!rther gro!ped into

SECRE($R' EN3INEER' $N$3ER' (ECNICI$N'S$$RIE56E/1EE' 17R6E/1EE'8 9  Eah o" these gro!pings is a s!#set o" E/1EE entities

 9  Eah is alled a s!#lass o" E/1EE

 9  E/1EE is the s!perlass "or eah o" these s!#lasses

(hese are alled s!perlass&s!#lass relationships.

E*ample% E/1EE&SECRE($R'E/1EE&(ECNICI$N

Page 5: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 5/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Subclasses and Superclasses (2)

(hese are also alled IS)$ relationships +SECRE($R IS)$E/1EE' (ECNICI$N IS)$ E/1EE' 8,.

 Note% $n entity that is mem#er o" a s!#lass represents the same real):orld entity as some mem#er o" the s!perlass

 9  (he S!#lass mem#er is the same entity in a distint spei"i role

 9  $n entity annot e*ist in the data#ase merely #y #eing a mem#ero" a s!#lass; it m!st also #e a mem#er o" the s!perlass

 9  $ mem#er o" the s!perlass an #e optionally inl!ded as amem#er o" any n!m#er o" its s!#lasses

E*ample% $ salaried employee :ho is also an engineer #elongs to thet:o s!#lasses EN3INEER and S$$RIE56E/1EE

 9  It is not neessary that every entity in a s!perlass #e a mem#er o"some s!#lass

Page 6: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 6/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

 Attribute Inheritance in

Superclass / Subclass

Relationships$n entity that is mem#er o" a s!#lass inherits all

attri#!tes o" the entity as a mem#er o" the

s!perlassIt also inherits all relationships

Page 7: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 7/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Specialization

Is the proess o" de"ining a set o" s!#lasses o" a s!perlass (he set o" s!#lasses is #ased !pon some disting!ishing harateristis

o" the entities in the s!perlass E*ample% <SECRE($R' EN3INEER' (ECNICI$N= is a

speialization o" E/1EE #ased !pon job type. 9  ay have several speializations o" the same s!perlass

E*ample% $nother speialization o" E/1EE #ased in method of pay is <S$$RIE56E/1EE' 17R6E/1EE=.

 9  S!perlass&s!#lass relationships and speialization an #e

diagrammatially represented in EER diagrams 9  $ttri#!tes o" a s!#lass are alled spei"i attri#!tes. >or e*ample'(ypingSpeed o" SECRE($R

 9  (he s!#lass an partiipate in spei"i relationship types. >ore*ample' BE1N3S6(1 o" 17R6E/1EE

Page 8: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 8/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Exaple o! a Specialization

Page 9: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 9/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

"eneralization

(he reverse o" the speialization proess

Several lasses :ith ommon "eat!res are generalized into

a s!perlass; original lasses #eome its s!#lasses

E*ample% C$R' (R7C? generalized into @EICE; #oth

C$R' (R7C? #eome s!#lasses o" the s!perlass

@EICE.

 9  Ae an vie: <C$R' (R7C?= as a speialization o" @EICE

 9  $lternatively' :e an vie: @EICE as a generalization o" C$R

and (R7C?

Page 10: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 10/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

"eneralization and

Specialization 5iagrammati notation sometimes !sed to disting!ish #et:een

generalization and speialization

 9  $rro: pointing to the generalized s!perlass represents ageneralization

 9  $rro:s pointing to the speialized s!#lasses represent aspeialization

 9  Ae do not !se this notation #ea!se it is o"ten s!#-etive as to:hih proess is more appropriate "or a parti!lar sit!ation

 9  Ae advoate not dra:ing any arro:s in these sit!ations

5ata odeling :ith Speialization and 3eneralization 9  $ s!perlass or s!#lass represents a set o" entities

 9  Sho:n in retangles in EER diagrams +as are entity types,

 9  Sometimes' all entity sets are simply alled lasses' :hether theyare entity types' s!perlasses' or s!#lasses

Page 11: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 11/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Constraints on Specialization

and "eneralization (1) I" :e an determine e*atly those entities that :ill #eome mem#ers o" eah

s!#lass #y a ondition' the s!#lasses are alled predicate-defined  +orondition)de"ined, s!#lasses

 9  Condition is a onstraint that determines s!#lass mem#ers

 9  5isplay a prediate)de"ined s!#lass #y :riting the prediate ondition ne*tto the line attahing the s!#lass to its s!perlass I" all s!#lasses in a speialization have mem#ership ondition on same attri#!te

o" the s!perlass' speialization is alled an attribute defined )speialization

 9  $ttri#!te is alled the de"ining attri#!te o" the speialization

 9  E*ample% o#(ype is the de"ining attri#!te o" the speialization<SECRE($R' (ECNICI$N' EN3INEER= o" E/1EE

I" no ondition determines mem#ership' the s!#lass is alled user-defined   9  em#ership in a s!#lass is determined #y the data#ase !sers #y applying

an operation to add an entity to the s!#lass

 9  em#ership in the s!#lass is spei"ied individ!ally "or eah entity in thes!perlass #y the !ser

Page 12: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 12/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Constraints on Specialization

and "eneralization (2) (:o other onditions apply to a speialization&generalization% Disjointness Constraint%

 9  Spei"ies that the s!#lasses o" the speialization m!st #e dis-ointed +anentity an #e a mem#er o" at most one o" the s!#lasses o" the

speialization, 9  Spei"ied #y d in EER diagram

 9  I" not dis-ointed' overlap; that is the same entity may #e a mem#er o"more than one s!#lass o" the speialization

 9  Spei"ied #y o in EER diagram

Completeness Constraint%

 9  (otal spei"ies that every entity in the s!perlass m!st #e a mem#er o"some s!#lass in the speialization& generalization

 9  Sho:n in EER diagrams #y a do!#le line

 9  /artial allo:s an entity not to #elong to any o" the s!#lasses

 9  Sho:n in EER diagrams #y a single line

Page 13: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 13/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Constraints on Specialization

and "eneralization (#) ene' :e have "o!r types o" speialization&generalization%

 9  5is-oint' total

 9  5is-oint' partial

 9  1verlapping' total

 9  1verlapping' partial

 Note% 3eneralization !s!ally is total #ea!se the s!perlass is derived"rom the s!#lasses.

Page 14: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 14/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Exaple o! dis$oint partial

Specialization

Page 15: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 15/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Specialization / "eneralization

%ierarchies& 'attices and Shared

Subclasses $ s!#lass may itsel" have "!rther s!#lasses spei"ied on it >orms a hierarhy or a lattie ierarhy has a onstraint that every s!#lass has only one s!perlass +alled  single

inheritance, In a lattie' a s!#lass an #e s!#lass o" more than one s!perlass +alled multiple

inheritance, In a lattie or hierarhy' a s!#lass inherits attri#!tes not only o" its diret

s!perlass' #!t also o" all its predeessor s!perlasses $ s!#lass :ith more than one s!perlass is alled a shared s!#lass Can have speialization hierarhies or latties' or generalization hierarhies or

latties In speialization' start :ith an entity type and then de"ine s!#lasses o" the entity

type #y s!essive speialization +top do:n onept!al re"inement proess, In generalization' start :ith many entity types and generalize those that have

ommon properties +#ottom !p onept!al synthesis proess, In pratie' the om#ination o" t:o proesses is employed

Page 16: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 16/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Specialization / "eneralization

'attice Exaple (I*ERSI+,)

Page 17: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 17/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Cateories (I. +,ES)

$ll o" the s!perlass&s!#lass relationships :e have seen th!s "ar have a singles!perlass

$ shared s!#lass is s!#lass in more than one distint s!perlass&s!#lassrelationships' :here eah relationships has a single s!perlass +m!ltipleinheritane,

In some ases' need to model a single s!perlass&s!#lass relationship :ithmore than one s!perlass

S!perlasses represent di""erent entity types S!h a s!#lass is alled a ategory or 7NI1N (/E E*ample% 5ata#ase "or vehile registration' vehile o:ner an #e a person' a

 #ank +holding a lien on a vehile, or a ompany.

 9  Category +s!#lass, 1ANER is a s!#set o" the !nion o" the three s!perlassesC1/$N' B$N?' and /ERS1N

 9  $ ategory mem#er m!st e*ist in at least one o" its s!perlasses

 Note% (he di""erene "rom shared s!#lass' :hih is s!#set o" the intersetion o"its s!perlasses +shared s!#lass mem#er m!st e*ist in all o" its s!perlasses,.

Page 18: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 18/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

Exaple o! cateories

(I. +,ES)

Page 19: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 19/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

0oral e!initions o! EER

Model (1) Class C% $ set o" entities; o!ld #e entity type' s!#lass' s!perlass'

ategory. S!#lass S% $ lass :hose entities m!st al:ays #e s!#set o" the entities

in another lass' alled the s!perlass C o" the s!perlass&s!#lass +or

IS)$, relationship S&C%S C⊆

Speialization % D <S' S2'8' Sn= a set o" s!#lasses :ith sames!perlass 3; hene' 3&Si a s!perlass relationship "or i D ' 8.' n. 9  3 is alled a generalization o" the s!#lasses <S' S2'8' Sn=

 9  is total i" :e al:ays have%

S S2 8 Sn D 3;∪ ∪ ∪1ther:ise' is partial.

 9  is dis-oint i" :e al:ays have%

Si F S2 empty)set "or i G -;

1ther:ise' is overlapping.

Page 20: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 20/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

Copyright © 2004 Ramez Elmasri and Shamkant Navathe 

0oral e!initions o! EER

Model (2) S!#lass S o" C is prediate de"ined i" prediate p on attri#!tes o" C is !sed to

spei"y mem#ership in S; that is' S D CHp' :here CHp is the set o" entities in Cthat satis"y p

$ s!#lass not de"ined #y a prediate is alled !ser)de"ined

$ttri#!te)de"ined speialization% i" a prediate $ D i +:here $ is an attri#!te o" 3and i is a onstant val!e "rom the domain o" $, is !sed to spei"y mem#ership ineah s!#lass Si in

 Note% I" i G - "or i G -' and $ is single)val!ed' then the attri#!te)de"inedspeialization :ill #e dis-oint.

Category or 7NI1N type ( 9  $ lass that is a s!#set o" the !nion o" n de"ining s!perlasses

5' 52'85n' nJ%

( +5 52 8 5n,⊆ ∪ ∪ ∪$ prediate pi on the attri#!tes o" (.

 9  I" a prediate pi on the attri#!tes o" 5i an spei"y entities o" 5i that are mem#ers o" (.

 9  I" a prediate is spei"ied on every 5i% ( D +5Hp 52Hp2 8 5nHpn∪ ∪ ∪

 9   Note% (he de"inition o" relationship type sho!ld have Kentity typeK replaed :ith KlassK.

Page 21: Chapter 3. Enhanced Entity Relationship

7/21/2019 Chapter 3. Enhanced Entity Relationship

http://slidepdf.com/reader/full/chapter-3-enhanced-entity-relationship 21/21

Elmasri and Navathe, Fndamentals o! "ata#ase $ystems, Fourth Edition

M' Exaple !or isplain

Specialization / "eneralization