Professional Documents
Culture Documents
Lecture - 02 ERD
Lecture - 02 ERD
Spring 2020
• Sources of requirements
– User Interviews
– Forms
– Reports
– Queries
– Use Cases
– Business Rules
Requirements Become the
E-R Data Model
• After the requirements have been
gathered, they are transformed into
an Entity Relationship (E-R) Data
Model
• E-R Models consist of
– Entities
– Attributes
– Identifiers
– Relationships
Why Learn About Database
Modeling?
• The way in which data is stored is very important
for subsequent access and manipulation by SQL.
7
Entity Sets instructor and student
Preferences
Drinkers
name addr
A Typical Relationship Set
drinks
license
Drinkers
name addr
Drinkers frequent
some cafes.
Multiplicity of E/R Relations
• one-one:
1 a
2 b
3 c
d
• many-one
1 a
2 b
3 c
d
• many-many
1 a
2 b
3 c
d
Representing “Multiplicity”
• Show a many-one relationship by an
arrow entering the “one” side.
• Show a one-one relationship by arrows
entering both entity sets.
• In some situations, we can also assert
“exactly one,” i.e., each entity of one set
must be related to exactly one entity of the
other set. To do so, we use a rounded
arrow. (Referential Integrity will be
discussed later)
One-to-One Relationship
• one-to-one relationship between an instructor and a
student
– an instructor is associated with at most one student via advisor
– and a student is associated with at most one instructor via
advisor
One-to-Many Relationship
• one-to-many relationship between an instructor and a
student
– an instructor is associated with several (including 0) students
via advisor
– a student is associated with at most one instructor via advisor,
Many-to-One Relationships
• In a many-to-one relationship between an instructor and a
student,
– an instructor is associated with at most one student via advisor,
– and a student is associated with several (including 0) instructors
via advisor
Many-to-Many Relationship
• An instructor is associated with several (possibly 0)
students via advisor
• A student is associated with several (possibly 0)
instructors via advisor
Maximum Cardinality
• Relationships are named and classified by
their cardinality, which is a word that
means count
• Each of the three types of binary
relationships shown above have different
maximum cardinalities
• maximum cardinality is the maximum
number of entity instances that may
participate in a relationship instance—
one, many or some other fixed number
Minimum Cardinality
• Minimum cardinality is the
minimum number of entity instances
that must participate in a relationship
instance
• These values typically assume a
value of zero (optional) or one
(mandatory)
Cardinality Example
• Maximum cardinality is many for both
ITEM and SUPPLIER
• Minimum cardinality is zero (optional) for
ITEM and one (mandatory) SUPPLIER
– A SUPPLIER does not have to supply an
ITEM
– An ITEM must have a SUPPLIER
Attributes on Relationships
• Sometimes it is useful to attach an
attribute to a relationship.
• Think of this attribute as a property of
tuples in the relationship set.
price
isa
fruit Juices
Examples