Anda di halaman 1dari 53

Chapter11

EntityRelationshipmodeling
Transparencies

Pearson Education Limited 1995, 2005

Chapter11Objectives

HowtouseEntityRelationship(ER)modelingindatabase
design.

BasicconceptsassociatedwithERmodel.

DiagrammatictechniquefordisplayingERmodelusing
UnifiedModelingLanguage(UML).

HowtoidentifyandresolveproblemswithERmodelscalled
connectiontraps.

HowtobuildanERmodelfromarequirementsspecification.

Pearson Education Limited 1995, 2005

ERdiagramofBranchuserviewsof
DreamHome

Pearson Education Limited 1995, 2005

ConceptsoftheERModel

Entitytypes

Relationshiptypes

Attributes

Pearson Education Limited 1995, 2005

EntityType

Entitytype
Groupofobjectswithsameproperties,
identifiedbyenterpriseashavingan
independentexistence.

Entityoccurrence
Uniquelyidentifiableobjectofanentitytype.

Pearson Education Limited 1995, 2005

ExamplesofEntityTypes

Pearson Education Limited 1995, 2005

ERdiagramofStaffandBranchentitytypes

Pearson Education Limited 1995, 2005

RelationshipTypes

Relationshiptype
Setofmeaningfulassociationsamongentity
types.

Relationshipoccurrence
Uniquelyidentifiableassociation,which
includesoneoccurrencefromeach
participatingentitytype.

Pearson Education Limited 1995, 2005

SemanticnetofHasrelationshiptype

Pearson Education Limited 1995, 2005

ERdiagramofBranchHasStaffrelationship

Pearson Education Limited 1995, 2005

10

RelationshipTypes

DegreeofaRelationship
Numberofparticipatingentitiesinrelationship.

Relationshipofdegree:
twoisbinary
threeisternary
fourisquaternary.

Pearson Education Limited 1995, 2005

11

BinaryrelationshipcalledPOwns

Pearson Education Limited 1995, 2005

12

TernaryrelationshipcalledRegisters

Pearson Education Limited 1995, 2005

13

QuaternaryrelationshipcalledArranges

Pearson Education Limited 1995, 2005

14

RelationshipTypes

RecursiveRelationship
Relationshiptypewheresameentitytype
participatesmorethanonceindifferentroles.

Relationshipsmaybegivenrolenamesto
indicatepurposethateachparticipatingentity
typeplaysinarelationship.

Pearson Education Limited 1995, 2005

15

RecursiverelationshipcalledSupervises
withrolenames

Pearson Education Limited 1995, 2005

16

Entitiesassociatedthroughtwodistinct
relationshipswithrolenames

Pearson Education Limited 1995, 2005

17

Attributes

Attribute
Propertyofanentityorarelationshiptype.

AttributeDomain
Setofallowablevaluesforoneormore
attributes.

Pearson Education Limited 1995, 2005

18

Attributes

SimpleAttribute
Attributecomposedofasinglecomponent
withanindependentexistence.

CompositeAttribute
Attributecomposedofmultiplecomponents,
eachwithanindependentexistence.

Pearson Education Limited 1995, 2005

19

Attributes

SinglevaluedAttribute
Attributethatholdsasinglevalueforeach
occurrenceofanentitytype.

MultivaluedAttribute
Attributethatholdsmultiplevaluesforeach
occurrenceofanentitytype.

Pearson Education Limited 1995, 2005

20

Attributes

DerivedAttribute
Attributethatrepresentsavaluethatis
derivablefromvalueofarelatedattribute,
orsetofattributes,notnecessarilyinthe
sameentitytype.

Pearson Education Limited 1995, 2005

21

Keys

CandidateKey
Minimalsetofattributesthatuniquelyidentifieseach
occurrenceofanentitytype.

PrimaryKey
Candidatekeyselectedtouniquelyidentifyeach
occurrenceofanentitytype.

CompositeKey
Acandidatekeythatconsistsoftwoormoreattributes.

Pearson Education Limited 1995, 2005

22

ERdiagramofStaffandBranchentities
andtheirattributes

Pearson Education Limited 1995, 2005

23

EntityType

StrongEntityType
Entitytypethatisnotexistencedependent
onsomeotherentitytype.

WeakEntityType
Entitytypethatisexistencedependenton
someotherentitytype.

Pearson Education Limited 1995, 2005

24

StrongentitytypecalledClientandweak
entitytypecalledPreference

Pearson Education Limited 1995, 2005

25

RelationshipcalledAdvertiseswithattributes

Pearson Education Limited 1995, 2005

26

StructuralConstraints

Maintypeofconstraintonrelationshipsiscalled
multiplicity.

Multiplicitynumber(orrange)ofpossible
occurrencesofanentitytypethatmayrelatetoa
singleoccurrenceofanassociatedentitytype
throughaparticularrelationship.

Representspolicies(calledbusinessrules)established
byuserorcompany.
Pearson Education Limited 1995, 2005

27

StructuralConstraints

Themostcommondegreeforrelationshipsis
binary.

Binaryrelationshipsaregenerallyreferredto
asbeing:
onetoone(1:1)
onetomany(1:*)
manytomany(*:*)

Pearson Education Limited 1995, 2005

28

SemanticnetofStaffManagesBranch
relationshiptype

Pearson Education Limited 1995, 2005

29

MultiplicityofStaffManagesBranch(1:1)
relationship

Pearson Education Limited 1995, 2005

30

SemanticnetofStaffOversees
PropertyForRentrelationshiptype

Pearson Education Limited 1995, 2005

31

MultiplicityofStaffOverseesPropertyForRent
(1:*)relationshiptype

Pearson Education Limited 1995, 2005

32

SemanticnetofNewspaperAdvertises
PropertyForRentrelationshiptype

Pearson Education Limited 1995, 2005

33

MultiplicityofNewspaperAdvertises
PropertyForRent(*:*)relationship

Pearson Education Limited 1995, 2005

34

StructuralConstraints

MultiplicityforComplexRelationships
Number(orrange)ofpossibleoccurrences
ofanentitytypeinannaryrelationship
whenother(n1)valuesarefixed.

Pearson Education Limited 1995, 2005

35

SemanticnetofternaryRegistersrelationship
withvaluesforStaffandBranchentitiesfixed

Pearson Education Limited 1995, 2005

36

MultiplicityofternaryRegistersrelationship

Pearson Education Limited 1995, 2005

37

Summaryofmultiplicityconstraints

Pearson Education Limited 1995, 2005

38

StructuralConstraints

Multiplicityismadeupoftwotypesof
restrictionsonrelationships:cardinalityand
participation.

Pearson Education Limited 1995, 2005

39

StructuralConstraints

Cardinality
Describesmaximumnumberofpossible
relationshipoccurrencesforanentity
participatinginagivenrelationshiptype.

Participation
Determineswhetheralloronlysomeentity
occurrencesparticipateinarelationship.
Pearson Education Limited 1995, 2005

40

Multiplicityascardinalityandparticipation
constraints

Pearson Education Limited 1995, 2005

41

ProblemswithERModels

Problemsmayarisewhendesigninga
conceptualdatamodelcalledconnectiontraps.

Oftenduetoamisinterpretationofthe
meaningofcertainrelationships.

Twomaintypesofconnectiontrapsarecalled
fantrapsandchasmtraps.

Pearson Education Limited 1995, 2005

42

ProblemswithERModels

FanTrap
Whereamodelrepresentsarelationshipbetween
entitytypes,butpathwaybetweencertainentity
occurrencesisambiguous.

ChasmTrap
Whereamodelsuggeststheexistenceofa
relationshipbetweenentitytypes,butpathway
doesnotexistbetweencertainentityoccurrences.

Pearson Education Limited 1995, 2005

43

AnExampleofaFanTrap

Pearson Education Limited 1995, 2005

44

SemanticNetofERModelwithFanTrap

AtwhichbranchofficedoesstaffnumberSG37
work?
Pearson Education Limited 1995, 2005

45

RestructuringERmodeltoremoveFanTrap

Pearson Education Limited 1995, 2005

46

47

SemanticNetofRestructuredERModel
withFanTrapRemoved

SG37worksatbranchB003.
Pearson Education Limited 1995, 2005

48

49

AnExampleofaChasmTrap

Pearson Education Limited 1995, 2005

50

SemanticNetofERModelwithChasmTrap

AtwhichbranchofficeispropertyPA14
available?
Pearson Education Limited 1995, 2005

51

ERModelrestructuredtoremoveChasmTrap

Pearson Education Limited 1995, 2005

52

SemanticNetofRestructuredERModel
withChasmTrapRemoved

Pearson Education Limited 1995, 2005

53

Anda mungkin juga menyukai