Chapter 05
Chapter 05
Chapter 5
Advanced Data Modeling
1
Learning Objectives
●
Describe the main extended entity relationship (EER) model
constructs and how they are represented in ERDs and EERDs
●
Use entity clusters to represent multiple entities and
relationships in an entity relationship diagram (ERD)
●
Describe the characteristics of good primary keys and how to
select them
●
Apply flexible solutions for special data-modeling cases
2
Enhanced Entity Relationship Model
●
EERM
– Enhanced Entity Relationship Model
●
EERD
– Enhanced Entity Relationship Diagram
●
Adding more constructs to the ERM/ERD
3
Supertypes and Subtypes
●
Adding a bit of object-oriented concepts
●
Entity supertype (parent)
– A generic entity type that contains the common characteristics of
entity subtypes.
●
Entity subtype (child)
– A subset of an entity supertype
– The entity supertype contains the common characteristics and the
subtypes contain the unique characteristics
4
When to Use
●
There must be different, identifiable kinds of the entity in the user’s
environment
●
The different kinds of instances should each have one or more
attributes that are unique to that kind of instance
5
Specialization Hierarchy
●
Depicts arrangement of higher-level entity supertypes and
lower-level entity subtypes
●
Relationships are described in terms of “is-a” relationships
●
Subtype exists within the context of a supertype
●
Every subtype has one supertype to which it is directly
related
●
Supertype can have many subtypes
6
Allows...
●
Support attribute inheritance
●
Define a special supertype attribute known as
the subtype discriminator
●
Define disjoint or overlapping constraints and
complete or partial constraints
7
Example
8
Inheritance
●
All entity subtypes inherit their primary key attribute from their
supertype
●
At the implementation level, supertype and its subtype(s)
maintain a 1:1 relationship
●
Entity subtypes inherit all relationships in which supertype
entity participates
●
Lower-level subtypes inherit all attributes and relationships
from its upper-level supertypes
9
Example
10
Definitions
●
Subtype discriminator
– Attribute in the supertype entity that determines to which entity subtype the
supertype occurrence is related
●
Disjoint subtypes
– Each entity instance of the supertype can appear in only one of the
subtypes.
●
Overlapping subtypes
– Each entity instance of the supertype may appear in more than one
subtype.
11
Example
12
Entity Clustering
●
Replace a group of entities with a “virtual” entity
13
Clustering in an ERD
14
Completeness Constraint
●
Partial completeness
– The condition in which some supertype occurrences
might not be members of any subtype.
●
Total completeness
– The condition in which every supertype occurrence
must be a member of at least one subtype.
15
Completeness Constraint
16
Primary Key Review
●
Primary key
– Single attribute or a combination of attributes
●
Uniquely identifies each entity instance
●
Guarantees entity integrity
●
Works with foreign keys to implement
relationships
17
Natural Keys
●
Natural key or natural identifier
– Real-world identifier used to uniquely identify real-world
objects
●
Familiar to end users and forms part of their day-to-
day business vocabulary
●
Used as the primary key of the entity being modeled
18
Primary Key Guidelines
19
Composite Primary Keys
●
Composite Key
– Uses more than one attribute
●
Use as identifiers of composite entities
– Each primary key combination is allowed once in M:N relationship
●
Use as identifiers of weak entities
– Strong identifying relationship with the parent entity
– Represents a real-world object that is existence-dependent on another real-world
object
– Represented in the data model as two separate entities in a strong identifying
relationship
20
Composite Entities
21
Surrogate Primary Keys
●
Primary key used to simplify the identification of entity
instances
– Useful when there is no natural key
– Helpful if selected candidate key has embedded semantic
contents or is too long
●
Require ensuring that the candidate key of entity in
question performs properly
– Use “unique index” and “not null” constraints
22
Example
23
Design Pitfalls
●
Implementing 1:1 relationships
●
Time variant data
●
Fan traps
●
Redundant relationships
24
1:1 Relationships
●
Where to place the foreign key
– Place a foreign key in both entities
– Place a foreign key in one of the entities
25
Time Variant Data
●
Data whose values change over time and for which
a history of the data changes must be retained
●
Requires creating a new entity in a 1:M relationship
with the original entity
●
New entity contains the new value, date of the
change, and any other pertinent attribute
26
Example
27
Traps
●
Design trap
– Ocurs when a relationship is improperly or incompletely identified
– Represented in a way not consistent with the real world
●
Fan trap
– Occurs when one entity is in two 1:M relationships to other entities
– Produces an association among other entities not expressed in the
model
28
Fan Trap
29
Correct Design
30
Redundant Relationships
●
Occur when there are multiple relationship
paths between related entities
●
Relationships must remain consistent across
the model
●
Removing redundant relationships help simplify
the design
31
Example
32