Week 5 Entity Relationship Modeling
-
Upload
faisal-khan -
Category
Documents
-
view
225 -
download
0
Transcript of Week 5 Entity Relationship Modeling
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 1/51
Pearson Education © 2014
Week 5
Entity-Relationship Modeling
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 2/51
Pearson Education © 2014
2
Objectives
How to use Entity–Relationship (ER)modeling in database design.
Basic concepts associated with ER model.
Diagrammatic technique for displaying ERmodel using Unified Modeling Language
(UML).
How to identify and resolve problems withER models called connection traps.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 3/51
Pearson Education © 2014
3
ER diagram of Branch user
views of DreamHome
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 4/51
Pearson Education © 2014
4
Concepts of the ER Model
Entity types
Relationship types
Attributes
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 5/51
Pearson Education © 2014
5
Entity Type
Entity type
Group of objects with same properties,identified by enterprise as having an
independent existence.
Entity occurrence
Uniquely identifiable object of an entitytype.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 6/51
Pearson Education © 2014
6
Examples of Entity Types
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 7/51
Pearson Education © 2014
7
ER diagram of Staff and
Branch entity types
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 8/51
Pearson Education © 2014
8
Relationship Types
Relationship type
Set of meaningful associations amongentity types.
Relationship occurrence
Uniquely identifiable association, which
includes one occurrence from eachparticipating entity type.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 9/51
Pearson Education © 2014
9
Semantic net of Has
relationship type
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 10/51Pearson Education © 2014
10
ER diagram of Branch Has
Staff relationship
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 11/51Pearson Education © 2014
11
Relationship Types
Degree of a Relationship
Number of participating entities inrelationship.
• Relationship of degree :
– two is binary
– three is ternary– four is quaternary.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 12/51Pearson Education © 2014
12
Binary relationship called
POwns
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 13/51Pearson Education © 2014
13
Ternary relationship called Registers
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 14/51Pearson Education © 2014
14
Quaternary relationship called Arranges
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 15/51Pearson Education © 2014
15
Relationship Types
• Recursive Relationship– Relationship type where same entity type
participates more than once in different
roles.
• Relationships may be given role names to
indicate purpose that each participatingentity type plays in a relationship.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 16/51Pearson Education © 2014
16
Recursive relationship calledSupervises with role names
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 17/51Pearson Education © 2014
17
Entities associated through twodistinct relationships with rolenames
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 18/51Pearson Education © 2014
18
Attributes
• Attribute– Property of an entity or a relationship type.
• Attribute Domain– Set of allowable values for one or more
attributes.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 19/51Pearson Education © 2014
19
Attributes
• Simple Attribute– Attribute composed of a single component
with an independent existence.
• Composite Attribute– Attribute composed of multiple
components, each with an independentexistence.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 20/51Pearson Education © 2014
20
Attributes
• Single-valued Attribute– Attribute that holds a single value for each
occurrence of an entity type.
• Multi-valued Attribute– Attribute that holds multiple values for
each occurrence of an entity type.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 21/51Pearson Education © 2014
21
Attributes
• Derived Attribute– Attribute that represents a value that is
derivable from value of a related attribute,
or set of attributes, not necessarily in thesame entity type.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 22/51Pearson Education © 2014
22
Keys
• Candidate Key– Minimal set of attributes that uniquely
identifies each occurrence of an entity type.
• Primary Key– Candidate key selected to uniquely identify
each occurrence of an entity type.
• Composite Key– A candidate key that consists of two or
more attributes.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 23/51Pearson Education © 2014
23
ER diagram of Staff and
Branch entities and theirattributes
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 24/51
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 25/51Pearson Education © 2014
25
Strong entity type called Client
and weak entity type calledPreference
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 26/51Pearson Education © 2014
26
Relationship called Advertises
with attributes
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 27/51Pearson Education © 2014
27
Structural Constraints
• Main type of constraint on relationships iscalled multiplicity.
• Multiplicity - number (or range) ofpossible occurrences of an entity type thatmay relate to a single occurrence of an
associated entity type through a particularrelationship.
• Represents policies (called business rules)established b user or com an .
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 28/51
Pearson Education © 2014
28
Structural Constraints
• The most common degree forrelationships is binary.
• Binary relationships are generallyreferred to as being:– one-to-one (1:1)
–
one-to-many (1:*)– many-to-many (*:*)
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 29/51
Pearson Education © 2014
29
Semantic net of Staff Manages
Branch relationship type
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 30/51
Pearson Education © 2014
30
Multiplicity of Staff Manages
Branch (1:1) relationship
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 31/51
Pearson Education © 201431
Semantic net of Staff Oversees
PropertyForRent relationshiptype
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 32/51
Pearson Education © 201432
Multiplicity of Staff Oversees
PropertyForRent (1:*)relationship type
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 33/51
Pearson Education © 201433
Semantic net of Newspaper
Advertises PropertyForRentrelationship type
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 34/51
Pearson Education © 201434
Multiplicity of Newspaper
Advertises PropertyForRent(*:*) relationship
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 35/51
Pearson Education © 201435
Structural Constraints
• Multiplicity for Complex Relationships – Number (or range) of possible occurrences
of an entity type in an n-ary relationship
when other ( n-1) values are fixed.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 36/51
Pearson Education © 201436
Semantic net of ternary
Registers relationship withvalues for Staff and Branchentities fixed
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 37/51
Pearson Education © 201437
Multiplicity of ternary Registers relationship
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 38/51
Pearson Education © 201438
Summary of multiplicityconstraints
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 39/51
Pearson Education © 201439
Structural Constraints
• Multiplicity is made up of two types ofrestrictions on relationships: cardinality and participation.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 40/51
Pearson Education © 201440
Structural Constraints
• Cardinality– Describes maximum number of possible
relationship occurrences for an entityparticipating in a given relationship type.
• Participation– Determines whether all or only some entity
occurrences participate in a relationship.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 41/51
Pearson Education © 201441
Multiplicity as cardinality andparticipation constraints
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 42/51
Pearson Education © 201442
Problems with ER Models
• Problems may arise when designing aconceptual data model called connection
traps.
• Often due to a misinterpretation of themeaning of certain relationships.
• Two main types of connection traps arecalled fan traps and chasm traps.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 43/51
Pearson Education © 201443
Problems with ER Models
• Fan Trap– Where a model represents a relationship
between entity types, but pathway between
certain entity occurrences is ambiguous.
• Chasm Trap– Where a model suggests the existence of a
relationship between entity types, but pathwaydoes not exist between certain entityoccurrences.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 44/51
Pearson Education © 201444
An Example of a Fan Trap
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 45/51
Pearson Education © 201445
Semantic Net of ER Modelwith Fan Trap
• At which branch office does staff number SG37work?
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 46/51
Pearson Education © 201446
Restructuring ER model to
remove Fan Trap
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 47/51
Pearson Education © 201447
Semantic Net of RestructuredER Model with Fan TrapRemoved
• SG37 works at branch B003.
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 48/51
Pearson Education © 201448
An Example of a Chasm Trap
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 49/51
Pearson Education © 201449
Semantic Net of ER Model
with Chasm Trap
• At which branch office is property PA14available?
7/23/2019 Week 5 Entity Relationship Modeling
http://slidepdf.com/reader/full/week-5-entity-relationship-modeling 50/51
Pearson Education © 201450
ER Model restructured to
remove Chasm Trap