Lecture 10
Lecture 10
Lecture # 10
By
Maria Gul
1
Components of ER Model
Cardinality Constraints
• The number of instance of an entity type that can
be associated with each instance of another entity
type is called cardinality constraints.
Completes
STUDENT COURSES
3
Components of ER Model
Cardinality Constraints
Symbols used to show Degree
• A Circle : indicates that relationship is optional.
• A Stroke : indicates that relationship is
mandatory.
• A Crow’s Foot : indicates that many relationships
between instances of the related entities may
exist.
4
Components of ER Model
Cardinality Constraints
Mandatory One
Mandatory Many
Optional One
Optional Many
5
Cardinality Constraints
Minimum Cardinality
• Minimum number of instances of entity B that may
be associated with each instance of entity A.
A B
7
Relationship
Structural Constraints
8
Relationship
Multiplicity
9
Relationship
Multiplicity
One-to-One Relationship
Manages
STAFF o BRANCH
10
Relationship
Multiplicity
One-to-One Relationship
Determining the multiplicity
11
Relationship
Multiplicity
One-to-One Relationship
12
One-to-One (1:1) Relationships..
➢ By analyzing the semantic net, we can conclude as
follows:
14
One-to-One (1:1) Relationships
15
One-to-Many (1:*) Relationships
➢ Determining the multiplicity
❖ Consider the relationship Oversees, which
relates the Staff and PropertyForRent entity
types.
❖ A semantic net can be used displays sample
occurrences of the Oversees relationship
type.
16
One-to-Many (1:*) Relationships
17
One-to-Many (1:*) Relationships
➢ By analyzing the semantic net, we can conclude
as follows:
❖ The staffNo SG37 oversees propertyNos PG21
and PG36, and staffNo SA9 oversees
propertyNo PA14 but staffNo SG5 does not
oversee any properties for rent and
propertyNo PG4 is not overseen by any
member of staff.
❖ In summary, a member of staff can oversee
zero or more properties for rent and a
property for rent is overseen by zero or one
member of staff.
18
One-to-Many (1:*) Relationships
➢ By analyzing the semantic net, we can conclude
as follows:
❖ Therefore, for members of staff participating
in this relationship there are many properties
for rent, and for properties participating in
this relationship there is a maximum of one
member of staff, we refer to this type of
relationship as one-to-many.
19
One-to-Many (1:*) Relationships
➢ By analyzing the semantic net, we can
conclude as follows:
❖ The staffNo SG37 oversees propertyNos PG21
and PG36, and staffNo SA9 oversees
propertyNo PA14 but staffNo SG5 does not
oversee any properties for rent and
propertyNo PG4 is not overseen by any
member of staff.
❖ In summary, a member of staff can oversee
zero or more properties for rent and a
property for rent is overseen by zero or one
member of staff.
20
One-to-Many (1:*) Relationships
➢ By analyzing the semantic net, we can
conclude as follows:
❖ Therefore, for members of staff participating
in this relationship there are many properties
for rent, and for properties participating in
this relationship there is a maximum of one
member of staff, we refer to this type of
relationship as one-to-many.
21
One-to-Many (1:*) Relationships
22
One-to-Many (1:*) Relationships
➢ In case, we know the actual minimum and
maximum values for the multiplicity, we can
display these instead
23
Many-to-Many (*:*) Relationships
➢ Determining the multiplicity
❖ Consider the relationship Advertises, which
relates the Newspaper and
PropertyForRent entity types.
❖ A semantic net can be used displays
sample occurrences of the Advertises
relationship type.
24
Many-to-Many (*:*) Relationships
25
Many-to-Many (*:*) Relationships
➢ By analyzing the semantic net, we can conclude as
follows:
❖ The Glasgow Daily advertises propertyNos PG21
and PG36, the West News also advertises
propertyNo PG36 and the Aberdeen Express
advertises propertyNo PA14, however
propertyNo PG4 is not advertised in any
newspaper.
❖ In other words, one newspaper advertises one or
more properties for rent and one property for
rent is advertised in zero or more newspapers.
26
Many-to-Many (*:*) Relationships
➢ By analyzing the semantic net, we can conclude as
follows:
❖ Therefore, for newspapers there are many
properties for rent, and for each property for
rent participating in this relationship there are
many newspapers, we refer to this type of
relationship as many-to-many.
27
Many-to-Many (*:*) Relationships
28
ERD Case Study
• A SUPPLIER may supply many ITEMs (by “may supply,” mean
the supplier may not supply any items). Each ITEM is supplied by
any number of SUPPLIERs (by “is supplied,” we mean that the
item must be supplied by at least one supplier).
• Each ITEM must be used in the assembly of at least one
PRODUCT and may be used in many products. Conversely, each
PRODUCT must use one or more ITEMs.
• A SUPPLIER may send many SHIPMENTs. However, each
SHIPMENT must be sent by exactly one SUPPLIER.
• A SHIPMENT must include one (or more) ITEMs. An ITEM may
be included on several SHIPMENTs.
• A CUSTOMER may submit any number of ORDERs. However,
each ORDER must be submitted by exactly one CUSTOMER.
• An ORDER must request one (or more) PRODUCTs. A given
PRODUCT may not be requested on any ORDER, or may be
requested on one or more orders.
29
ERD Case Study
30
Cardinality Constraints
31