Er 2
Er 2
ENTITY-RELATIONSHIP MODEL
CS121: Introduction to Relational Database Systems
Fall 2016 – Lecture 14
Designing Database Applications
2
¤ Incomplete representation
n Schema must be able to fully represent all details and
relationships required by the application
More Design Decisions
8
¤ city
¨ Relationship-set is a diamond
¤ Connected to participating entity-sets by solid lines
¨ Relationship-set can have descriptive attributes
¤ Listed in another box, connected with a dotted-line
Attribute Structure
22
Given:
¨ Entity-sets A and B A B
¨ Binary relationship-set R a1 b1
associating A and B
a2 b2
a3 b3
One-to-one mapping (1:1)
¨ An entity in A is associated a4 b4
with at most one entity in B
¨ An entity in B is associated
with at most one entity in A
Mapping Cardinalities (3)
31
a2 b3
Many-to-one mapping (M:1)
a3 b4
¨ Opposite of one-to-many
Many-to-many mapping
A B
¨ An entity in A is associated with
a1 b1
zero or more entities in B
¨ An entity in B is associated with a2 b2
zero or more entities in A a3 b3
a4 b4
a5 b5
Mapping Cardinalities (5)
33
¨ In relationship-set diagrams:
¤ an arrow towards an entity represents “one”
¤ a simple line represents “many”
¤ arrow is always towards the entity
¨ Many-to-many mapping between customer and
loan:
access_date
customer
cust_id loan
name borrower loan_id
street_address amount
city
Diagramming Cardinalities (2)
36