04 The Entity Relationship Model
04 The Entity Relationship Model
Simon Miner
Gordon College
Last Revised: 9/20/12
Agenda
Check-in
Group Exercise
Mapping Constraints
Restrictions as to what kind of subsets are possible
in a relationship set
Mapping cardinalities how many entities in each
entity set can participate in the relationship
Participation constraints when an entity in one
entity set must participate in a relationship
Existence dependencies when an entity in one
entity set of a relationship is dependent on the
existence of an entity in the other entity set
Primary keys for relationship sets
Mapping Cardinalities
One to one
Any member of either entity set involved can participate in at most one
instance of the relationship set
Often represented by arrow heads pointing to both entities arrow in E-R
diagrams
Many to many
Entities in either entity set can participate in multiple relationships
Often represented by a solid line to all entities in the relationship (no
arrow heads)
Participation Constraints
Total participation constraint
When the underlying of a relationship dictates that
every entity in on entity set must participate in an
instance of the relationship
One the one extreme, you can have a universal relation (in which all
attributes reside within a single relation scheme)
Everything
borrower_id, last_name, first_name, // from borrower
call_number, copy_number,
accession_number, title, author // from book
date_due // from checked_out
)
Formal definition
For some relation scheme R decomposed into two or more
schemes (R1, R2, Rn)
Where R = R1 R2 Rn
A lossless-join decomposition means that for every legal instance
r of R decomposed into r1, r2, rn of R1, R2, and Rn
r = r1 |X| r2 |X| |X| rn
Database Design Goal
Formal definition
For some relation scheme R and attribute sets A (A R) and
B (B R)
A B if for any legal relation on R
If there are two tuples t1 and t2 such that t1(A) = t2(A)
It must be the case that t2(A) = t2(B)
Finding Functional
Dependencies
From keys of an entity
A BC
FDs from One to Many /
Many to One Relationships
A BC
W XY
A BCMWXY
FDs from One to One
Relationships
A BC
W XY
A BCMWXY
W XYMABC
FDs from Many to Many
Relationships
A BC
W XY
AW M
Implied Functional
Dependencies
Initial set of FDs logically implies other FDs
If A B and B C, then B C
Closure
If F is the set of functional dependencies we develop
from the logic of the underlying reality
Then F+ (the transitive closure of F) is the set consisting
of all the dependencies of F, plus all the dependencies
they imply
Rules for Computing F+