Date post: | 26-May-2015 |
Category: |
Technology |
Upload: | sonabir |
View: | 368 times |
Download: | 0 times |
Chapter 3Chapter 3
Entity Relationship (E-Entity Relationship (E-R) ModelingR) Modeling
2
In this chapter, you will In this chapter, you will learn:learn:
What a conceptual model is and what What a conceptual model is and what its purpose isits purpose is
The difference between internal and The difference between internal and external modelsexternal models
How internal and external models How internal and external models serve the database design processserve the database design process
How relationships between entities How relationships between entities are defined and refined, and how such are defined and refined, and how such relationships are incorporated into relationships are incorporated into the database design processthe database design process
How ERD components affect database How ERD components affect database design and implementationdesign and implementation
3
Basic Modeling Basic Modeling ConceptsConcepts
Art and scienceArt and science Good judgment coupled with Good judgment coupled with
powerful design toolspowerful design tools ModelsModels
““Description or analogy used to Description or analogy used to visualize something that cannot be visualize something that cannot be directly observed” directly observed” Webster’s Webster’s DictionaryDictionary
4
Basic Modeling Basic Modeling ConceptsConcepts
Data ModelData Model Relatively simple representation of Relatively simple representation of
complex real-world data structurescomplex real-world data structures Basic tools for database designBasic tools for database design AbstractionAbstraction Good database design starts with a Good database design starts with a
good design of data model.good design of data model.
5
Basic Modeling Basic Modeling ConceptsConcepts
Data ModelData Model Different views of data and different Different views of data and different
concernsconcerns Communication is needed.Communication is needed. Impacts on overall management Impacts on overall management
system and policy, as well as decision system and policy, as well as decision make.make.
Blueprint, architecture, frameworkBlueprint, architecture, framework
6
Data Models: Degrees of Data Data Models: Degrees of Data AbstractionAbstraction
Three different models Three different models (according to the degree of (according to the degree of abstract)abstract) Conceptual model
o Global view of dataGlobal view of datao Basis for identification and description of main Basis for identification and description of main
data itemsdata items Internal model
o Representation of database as seen by DBMSRepresentation of database as seen by DBMSo Adapts conceptual model to specific DBMSAdapts conceptual model to specific DBMS
External modelo Based on internal data modelBased on internal data modelo Users’ views of data environmentUsers’ views of data environmento Provides subsets of internal viewProvides subsets of internal view
Physical modelo Lowest level of abstractionLowest level of abstractiono Describe the ways data being storedDescribe the ways data being stored
7
8
The Entity Relationship The Entity Relationship (E-R) Model(E-R) Model
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 What Should an Entity Be?Be?
SHOULD BE:SHOULD BE: An object that will have many An object that will have many
instances in the databaseinstances in the database An object that will be composed of An object that will be composed of
multiple attributesmultiple attributes 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 system A user of the database system An output of the database system (e.g. An output of the database system (e.g.
a report)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 into Can be subdivided into
additional attributesadditional attributes Address into street, city, zipAddress into street, city, zip
Single-valuedSingle-valued Can have only a single Can have only a single
valuevalue Person has one social Person has one social
security numbersecurity number
Multi-valued Multi-valued (avoid) in RDBMS(avoid) in RDBMS Can have many valuesCan have many values Person may have Person may have
several college several college degreesdegrees
How to avoid? (see How to avoid? (see next slide)next slide)
DerivedDerived Can be derived with Can be derived with
algorithm (Age can be algorithm (Age can be derived from date of derived from date of birth)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 in Operate in bothboth directions directions Connectivity describes relationship Connectivity describes relationship
classificationclassification 1:1, 1:M, M:N1:1, 1:M, M:N
CardinalityCardinality Expresses number of entity occurrences Expresses 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 Relationship ParticipationParticipation
22
Relationship StrengthRelationship Strength Existence dependenceExistence dependence
Entity’s existence depends on existence Entity’s existence depends on existence of related entitiesof related entities
Existence-independent entities can exist Existence-independent entities can exist apart from related entitiesapart from related entities
Example:Example:
23
Relationship StrengthRelationship Strength Weak (non-identifying)Weak (non-identifying)
One entity is existence-independent on One entity is existence-independent on anotheranother
PK of related entity doesn’t contain PK PK of related entity doesn’t contain PK component of parent entitycomponent of parent entity
Strong (identifying)Strong (identifying) One entity is existence-dependent on One entity is existence-dependent on
anotheranother PK of related entity contains PK PK of related entity contains PK
component of parent entity component of parent entity
24
25
26
Weak EntityWeak Entity Existence-dependent on another Existence-dependent on another
entityentity Has primary key that is partially Has primary key that is partially
or totally 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 Three Types of RelationshipsRelationships
Figure 3.21
29
30
Composite EntitiesComposite Entities
Used to ‘bridge’ between M:N Used to ‘bridge’ between M:N relationshipsrelationships
Bridge entities composed of Bridge entities composed of primary keys of each entity primary keys of each entity needing connectionneeding connection
Figure 3.30
31
Composite Entities Composite Entities (con’t.)(con’t.)
Figure 3.31
32
Entity Supertypes and Entity Supertypes and SubtypesSubtypes
Generalization hierarchy Generalization hierarchy Depicts relationships between higher-Depicts relationships between higher-
level supertype and lower-level subtype level supertype and lower-level subtype entitiesentities
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 Generalization Hierarchy with Hierarchy with
Overlapping SubtypesOverlapping Subtypes
Figure 3.35
37
Developing an E-R Developing an E-R DiagramDiagram
Iterative ProcessIterative Process Step1: General narrative of Step1: General narrative of
organizational operations developedorganizational operations developed Step2: Basic E-R Model graphically Step2: Basic E-R Model graphically
depicted and revieweddepicted and reviewed Step3: Modifications made to incorporate Step3: Modifications made to incorporate
newly discovered E-R componentsnewly discovered E-R components Repeat process until designers and Repeat process until designers and
users agree E-R Diagram completeusers agree E-R Diagram complete
38
Supertype/Subtype Supertype/Subtype Relationship in an ERD Relationship in an ERD
39
40
41
First ERD Segment First ERD Segment Established Established
Figure 3.43
42
Second and Third ERD Second and Third ERD Segments Established Segments Established
43
Fourth and Fifth ERD Fourth and Fifth ERD Segments Established Segments Established
44
Sixth and Seventh ERD Sixth and Seventh ERD Segments Established Segments Established
45
Eighth ERD Eighth ERD Segment Established Segment Established
46
Ninth ERD Ninth ERD Segment Established Segment Established
Figures 3.51
47
Components of E-R Components of E-R ModelModel
Table 3.2
48
Completed ERDCompleted ERD
Figure 3.52