Chapter 3Chapter 3
Entity Relationship (E-R)Entity Relationship (E-R)
ModelingModeling
2
In this chapter, you will learn:In this chapter, you will learn:
 What a conceptual model is and what itsWhat a conceptual model is and what its
purpose ispurpose is
 The difference between internal and externalThe difference between internal and external
modelsmodels
 How internal and external models serve theHow internal and external models serve the
database design processdatabase design process
 How relationships between entities are definedHow relationships between entities are defined
and refined, and how such relationships areand refined, and how such relationships are
incorporated into the database design processincorporated into the database design process
 How ERD components affect database design andHow ERD components affect database design and
implementationimplementation
3
Basic Modeling ConceptsBasic Modeling Concepts
 Art and scienceArt and science
 Good judgment coupled with powerfulGood judgment coupled with powerful
design toolsdesign tools
 ModelsModels
 ““Description or analogy used to visualizeDescription or analogy used to visualize
something that cannot be directly observed”something that cannot be directly observed”
Webster’s DictionaryWebster’s Dictionary
4
Basic Modeling ConceptsBasic Modeling Concepts
 Data ModelData Model
 Relatively simple representation of complex real-Relatively simple representation of complex real-
world data structuresworld data structures
 Basic tools for database designBasic tools for database design
 AbstractionAbstraction
 Good database design starts with a good designGood database design starts with a good design
of data model.of data model.
5
Basic Modeling ConceptsBasic Modeling Concepts
 Data ModelData Model
 Different views of data and different concernsDifferent views of data and different concerns
 Communication is needed.Communication is needed.
 Impacts on overall management system andImpacts on overall management system and
policy, as well as decision make.policy, as well as decision make.
 Blueprint, architecture, frameworkBlueprint, architecture, framework
6
Data Models: Degrees of Data AbstractionData Models: Degrees of Data Abstraction
 Three different modelsThree different models (according to the degree of abstract)(according to the degree of abstract)
 Conceptual model
o Global view of dataGlobal view of data
o Basis for identification and description of main data itemsBasis for identification and description of main data items
 Internal model
o Representation of database as seen by DBMSRepresentation of database as seen by DBMS
o Adapts conceptual model to specific DBMSAdapts conceptual model to specific DBMS
 External model
o Based on internal data modelBased on internal data model
o Users’ views of data environmentUsers’ views of data environment
o Provides subsets of internal viewProvides subsets of internal view
 Physical model
o Lowest level of abstractionLowest level of abstraction
o Describe the ways data being storedDescribe the ways data being stored
7
8
The Entity Relationship (E-R)The Entity Relationship (E-R)
ModelModel
 Represents conceptual viewRepresents conceptual view
 Main ComponentsMain Components
 EntitiesEntities
 Corresponds to entire table, not rowCorresponds to entire table, not row
 Represented by rectangleRepresented by rectangle
 AttributesAttributes
 RelationshipsRelationships
9
What Should an Entity Be?What Should an Entity Be?
 SHOULD BE:SHOULD BE:
 An object that will have many instances in theAn object that will have many instances in the
databasedatabase
 An object that will be composed of multipleAn object that will be composed of multiple
attributesattributes
 An object that we are trying to modelAn object that we are trying to model
 SHOULD NOT BE:SHOULD NOT BE:
 A user of the database systemA user of the database system
 An output of the database system (e.g. a report)An output of the database system (e.g. a report)
10
Inappropriate entities
System userSystem user System outputSystem output
Appropriate entities
Figure 3-4
11
AttributesAttributes
 Characteristics of entitiesCharacteristics of entities
 Domain is set of possible valuesDomain is set of possible values
 Primary keys underlinedPrimary keys underlined
Figure 3.6
12
13
 SimpleSimple
 Cannot be subdividedCannot be subdivided
 Age, sex, marital statusAge, sex, marital status
 Composite (avoided)Composite (avoided)
 Can be subdivided intoCan be subdivided into
additional attributesadditional attributes
 Address into street, city,Address into street, city,
zipzip
 Single-valuedSingle-valued
 Can have only a singleCan have only a single
valuevalue
 Person has one socialPerson has one social
security numbersecurity number
 Multi-valued (avoid) inMulti-valued (avoid) in
RDBMSRDBMS
 Can have many valuesCan have many values
 Person may have severalPerson may have several
college degreescollege degrees
 How to avoid? (see nextHow to avoid? (see next
slide)slide)
 DerivedDerived
 Can be derived withCan be derived with
algorithm (Age can bealgorithm (Age can be
derived from date of birth)derived from date of birth)
 Need to be storedNeed to be stored
14
15
16
17
18
19
RelationshipsRelationships
 Association between entitiesAssociation between entities
 Connected entities are called participantsConnected entities are called participants
 Operate inOperate in bothboth directionsdirections
 Connectivity describes relationshipConnectivity describes relationship
classificationclassification
 1:1, 1:M, M:N1:1, 1:M, M:N
 CardinalityCardinality
 Expresses number of entity occurrencesExpresses number of entity occurrences
associated with one occurrence of related entityassociated with one occurrence of related entity
20
Connectivity and Cardinality in an ERDConnectivity and Cardinality in an ERD
Figure 3.12
Relationship ParticipationRelationship Participation
22
Relationship StrengthRelationship Strength
 Existence dependenceExistence dependence
 Entity’s existence depends on existence of relatedEntity’s existence depends on existence of related
entitiesentities
 Existence-independent entities can exist apart fromExistence-independent entities can exist apart from
related entitiesrelated entities
 Example:Example:
23
Relationship StrengthRelationship Strength
 Weak (non-identifying)Weak (non-identifying)
 One entity is existence-independent on anotherOne entity is existence-independent on another
 PK of related entity doesn’t contain PK component ofPK of related entity doesn’t contain PK component of
parent entityparent entity
 Strong (identifying)Strong (identifying)
 One entity is existence-dependent on anotherOne entity is existence-dependent on another
 PK of related entity contains PK component of parentPK of related entity contains PK component of parent
entityentity
24
25
26
Weak EntityWeak Entity
 Existence-dependent on another entityExistence-dependent on another entity
 Has primary key that is partially or totallyHas primary key that is partially or totally
derived from parent entityderived from parent entity
Figure 3.19
27
Relationship DegreeRelationship Degree
 Indicates number of associated entitiesIndicates number of associated entities
 UnaryUnary
 Single entitySingle entity
 RecursiveRecursive
 Exists between occurrences of same entity setExists between occurrences of same entity set
 BinaryBinary
 Two entities associatedTwo entities associated
 TernaryTernary
 Three entities associatedThree entities associated
28
Three Types of RelationshipsThree Types of Relationships
Figure 3.21
29
30
Composite EntitiesComposite Entities
 Used to ‘bridge’ between M:N relationshipsUsed to ‘bridge’ between M:N relationships
 Bridge entities composed of primary keys ofBridge entities composed of primary keys of
each entity needing connectioneach entity needing connection
Figure 3.30
31
Composite Entities (con’t.)Composite Entities (con’t.)
Figure 3.31
32
Entity Supertypes and SubtypesEntity Supertypes and Subtypes
 Generalization hierarchyGeneralization hierarchy
 Depicts relationships between higher-levelDepicts relationships between higher-level
supertype and lower-level subtype entitiessupertype and lower-level subtype entities
 Supertype has shared attributesSupertype has shared attributes
 Subtypes have unique attributesSubtypes have unique attributes
 Disjoint relationshipsDisjoint relationships
 Unique subtypesUnique subtypes
 Non-overlappingNon-overlapping
 Indicated with a ‘G’Indicated with a ‘G’
 Overlapping subtypes use ‘Gs’ SymbolOverlapping subtypes use ‘Gs’ Symbol
33
34
35
36
Generalization Hierarchy withGeneralization Hierarchy with
Overlapping SubtypesOverlapping Subtypes
Figure 3.35
37
Developing an E-R DiagramDeveloping an E-R Diagram
 Iterative ProcessIterative Process
 Step1: General narrative of organizationalStep1: General narrative of organizational
operations developedoperations developed
 Step2: Basic E-R Model graphically depicted andStep2: Basic E-R Model graphically depicted and
reviewedreviewed
 Step3: Modifications made to incorporate newlyStep3: Modifications made to incorporate newly
discovered E-R componentsdiscovered E-R components
 Repeat process until designers and users agreeRepeat process until designers and users agree
E-R Diagram completeE-R Diagram complete
38
Supertype/SubtypeSupertype/Subtype
Relationship in an ERDRelationship in an ERD
39
40
41
First ERD SegmentFirst ERD Segment
EstablishedEstablished
Figure 3.43
42
Second and Third ERDSecond and Third ERD
Segments EstablishedSegments Established
43
Fourth and Fifth ERDFourth and Fifth ERD
Segments EstablishedSegments Established
44
Sixth and Seventh ERDSixth and Seventh ERD
Segments EstablishedSegments Established
45
Eighth ERDEighth ERD
Segment EstablishedSegment Established
46
Ninth ERDNinth ERD
Segment EstablishedSegment Established
Figures 3.51
47
Components of E-R ModelComponents of E-R Model
Table 3.2
48
Completed ERDCompleted ERD
Figure 3.52

Erd chapter 3

  • 1.
    Chapter 3Chapter 3 EntityRelationship (E-R)Entity Relationship (E-R) ModelingModeling
  • 2.
    2 In this chapter,you will learn:In this chapter, you will learn:  What a conceptual model is and what itsWhat a conceptual model is and what its purpose ispurpose is  The difference between internal and externalThe difference between internal and external modelsmodels  How internal and external models serve theHow internal and external models serve the database design processdatabase design process  How relationships between entities are definedHow relationships between entities are defined and refined, and how such relationships areand refined, and how such relationships are incorporated into the database design processincorporated into the database design process  How ERD components affect database design andHow ERD components affect database design and implementationimplementation
  • 3.
    3 Basic Modeling ConceptsBasicModeling Concepts  Art and scienceArt and science  Good judgment coupled with powerfulGood judgment coupled with powerful design toolsdesign tools  ModelsModels  ““Description or analogy used to visualizeDescription or analogy used to visualize something that cannot be directly observed”something that cannot be directly observed” Webster’s DictionaryWebster’s Dictionary
  • 4.
    4 Basic Modeling ConceptsBasicModeling Concepts  Data ModelData Model  Relatively simple representation of complex real-Relatively simple representation of complex real- world data structuresworld data structures  Basic tools for database designBasic tools for database design  AbstractionAbstraction  Good database design starts with a good designGood database design starts with a good design of data model.of data model.
  • 5.
    5 Basic Modeling ConceptsBasicModeling Concepts  Data ModelData Model  Different views of data and different concernsDifferent views of data and different concerns  Communication is needed.Communication is needed.  Impacts on overall management system andImpacts on overall management system and policy, as well as decision make.policy, as well as decision make.  Blueprint, architecture, frameworkBlueprint, architecture, framework
  • 6.
    6 Data Models: Degreesof Data AbstractionData Models: Degrees of Data Abstraction  Three different modelsThree different models (according to the degree of abstract)(according to the degree of abstract)  Conceptual model o Global view of dataGlobal view of data o Basis for identification and description of main data itemsBasis for identification and description of main data items  Internal model o Representation of database as seen by DBMSRepresentation of database as seen by DBMS o Adapts conceptual model to specific DBMSAdapts conceptual model to specific DBMS  External model o Based on internal data modelBased on internal data model o Users’ views of data environmentUsers’ views of data environment o Provides subsets of internal viewProvides subsets of internal view  Physical model o Lowest level of abstractionLowest level of abstraction o Describe the ways data being storedDescribe the ways data being stored
  • 7.
  • 8.
    8 The Entity Relationship(E-R)The Entity Relationship (E-R) ModelModel  Represents conceptual viewRepresents conceptual view  Main ComponentsMain Components  EntitiesEntities  Corresponds to entire table, not rowCorresponds to entire table, not row  Represented by rectangleRepresented by rectangle  AttributesAttributes  RelationshipsRelationships
  • 9.
    9 What Should anEntity Be?What Should an Entity Be?  SHOULD BE:SHOULD BE:  An object that will have many instances in theAn object that will have many instances in the databasedatabase  An object that will be composed of multipleAn object that will be composed of multiple attributesattributes  An object that we are trying to modelAn object that we are trying to model  SHOULD NOT BE:SHOULD NOT BE:  A user of the database systemA user of the database system  An output of the database system (e.g. a report)An output of the database system (e.g. a report)
  • 10.
    10 Inappropriate entities System userSystemuser System outputSystem output Appropriate entities Figure 3-4
  • 11.
    11 AttributesAttributes  Characteristics ofentitiesCharacteristics of entities  Domain is set of possible valuesDomain is set of possible values  Primary keys underlinedPrimary keys underlined Figure 3.6
  • 12.
  • 13.
    13  SimpleSimple  Cannotbe subdividedCannot be subdivided  Age, sex, marital statusAge, sex, marital status  Composite (avoided)Composite (avoided)  Can be subdivided intoCan be subdivided into additional attributesadditional attributes  Address into street, city,Address into street, city, zipzip  Single-valuedSingle-valued  Can have only a singleCan have only a single valuevalue  Person has one socialPerson has one social security numbersecurity number  Multi-valued (avoid) inMulti-valued (avoid) in RDBMSRDBMS  Can have many valuesCan have many values  Person may have severalPerson may have several college degreescollege degrees  How to avoid? (see nextHow to avoid? (see next slide)slide)  DerivedDerived  Can be derived withCan be derived with algorithm (Age can bealgorithm (Age can be derived from date of birth)derived from date of birth)  Need to be storedNeed to be stored
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    19 RelationshipsRelationships  Association betweenentitiesAssociation between entities  Connected entities are called participantsConnected entities are called participants  Operate inOperate in bothboth directionsdirections  Connectivity describes relationshipConnectivity describes relationship classificationclassification  1:1, 1:M, M:N1:1, 1:M, M:N  CardinalityCardinality  Expresses number of entity occurrencesExpresses number of entity occurrences associated with one occurrence of related entityassociated with one occurrence of related entity
  • 20.
    20 Connectivity and Cardinalityin an ERDConnectivity and Cardinality in an ERD Figure 3.12
  • 21.
  • 22.
    22 Relationship StrengthRelationship Strength Existence dependenceExistence dependence  Entity’s existence depends on existence of relatedEntity’s existence depends on existence of related entitiesentities  Existence-independent entities can exist apart fromExistence-independent entities can exist apart from related entitiesrelated entities  Example:Example:
  • 23.
    23 Relationship StrengthRelationship Strength Weak (non-identifying)Weak (non-identifying)  One entity is existence-independent on anotherOne entity is existence-independent on another  PK of related entity doesn’t contain PK component ofPK of related entity doesn’t contain PK component of parent entityparent entity  Strong (identifying)Strong (identifying)  One entity is existence-dependent on anotherOne entity is existence-dependent on another  PK of related entity contains PK component of parentPK of related entity contains PK component of parent entityentity
  • 24.
  • 25.
  • 26.
    26 Weak EntityWeak Entity Existence-dependent on another entityExistence-dependent on another entity  Has primary key that is partially or totallyHas primary key that is partially or totally derived from parent entityderived from parent entity Figure 3.19
  • 27.
    27 Relationship DegreeRelationship Degree Indicates number of associated entitiesIndicates number of associated entities  UnaryUnary  Single entitySingle entity  RecursiveRecursive  Exists between occurrences of same entity setExists between occurrences of same entity set  BinaryBinary  Two entities associatedTwo entities associated  TernaryTernary  Three entities associatedThree entities associated
  • 28.
    28 Three Types ofRelationshipsThree Types of Relationships Figure 3.21
  • 29.
  • 30.
    30 Composite EntitiesComposite Entities Used to ‘bridge’ between M:N relationshipsUsed to ‘bridge’ between M:N relationships  Bridge entities composed of primary keys ofBridge entities composed of primary keys of each entity needing connectioneach entity needing connection Figure 3.30
  • 31.
    31 Composite Entities (con’t.)CompositeEntities (con’t.) Figure 3.31
  • 32.
    32 Entity Supertypes andSubtypesEntity Supertypes and Subtypes  Generalization hierarchyGeneralization hierarchy  Depicts relationships between higher-levelDepicts relationships between higher-level supertype and lower-level subtype entitiessupertype and lower-level subtype entities  Supertype has shared attributesSupertype has shared attributes  Subtypes have unique attributesSubtypes have unique attributes  Disjoint relationshipsDisjoint relationships  Unique subtypesUnique subtypes  Non-overlappingNon-overlapping  Indicated with a ‘G’Indicated with a ‘G’  Overlapping subtypes use ‘Gs’ SymbolOverlapping subtypes use ‘Gs’ Symbol
  • 33.
  • 34.
  • 35.
  • 36.
    36 Generalization Hierarchy withGeneralizationHierarchy with Overlapping SubtypesOverlapping Subtypes Figure 3.35
  • 37.
    37 Developing an E-RDiagramDeveloping an E-R Diagram  Iterative ProcessIterative Process  Step1: General narrative of organizationalStep1: General narrative of organizational operations developedoperations developed  Step2: Basic E-R Model graphically depicted andStep2: Basic E-R Model graphically depicted and reviewedreviewed  Step3: Modifications made to incorporate newlyStep3: Modifications made to incorporate newly discovered E-R componentsdiscovered E-R components  Repeat process until designers and users agreeRepeat process until designers and users agree E-R Diagram completeE-R Diagram complete
  • 38.
  • 39.
  • 40.
  • 41.
    41 First ERD SegmentFirstERD Segment EstablishedEstablished Figure 3.43
  • 42.
    42 Second and ThirdERDSecond and Third ERD Segments EstablishedSegments Established
  • 43.
    43 Fourth and FifthERDFourth and Fifth ERD Segments EstablishedSegments Established
  • 44.
    44 Sixth and SeventhERDSixth and Seventh ERD Segments EstablishedSegments Established
  • 45.
    45 Eighth ERDEighth ERD SegmentEstablishedSegment Established
  • 46.
    46 Ninth ERDNinth ERD SegmentEstablishedSegment Established Figures 3.51
  • 47.
    47 Components of E-RModelComponents of E-R Model Table 3.2
  • 48.