0% found this document useful (0 votes)
35 views31 pages

Lecture 10

The document discusses components of the entity relationship (ER) model, including cardinality constraints and relationship types. Cardinality constraints specify the minimum and maximum number of relationships between entities. One-to-one relationships have a maximum of one entity of type B for each entity of type A. One-to-many relationships have many entities of type B for each entity of type A but maximum one entity of type A for each entity of type B. Many-to-many relationships have many entities of both types for each other. An example ER diagram is provided for suppliers, items, products, shipments and customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views31 pages

Lecture 10

The document discusses components of the entity relationship (ER) model, including cardinality constraints and relationship types. Cardinality constraints specify the minimum and maximum number of relationships between entities. One-to-one relationships have a maximum of one entity of type B for each entity of type A. One-to-many relationships have many entities of type B for each entity of type A but maximum one entity of type A for each entity of type B. Many-to-many relationships have many entities of both types for each other. An example ER diagram is provided for suppliers, items, products, shipments and customers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

CSC241 Database Systems

Entity Relationship Model

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

Each student completes one or more then one


courses but for each course there may or may not
exist student who complete the course.
2
Components of ER Model
Cardinality Constraints
Symbols used to show Degree
• A Circle
• A Stroke
• A Crow’s Foot

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

The minimum no. of instances of entity type B


are “0”. When minimum number of instance of
entity is zero we say that entity type is optional
participant.
6
Cardinality Constraints
Maximum Cardinality
• Maximum number of instances of entity B that may
be associated with each instance of entity A.
A B

The maximum no. of instances of entity type


B are unspecified but “many” and greater
than one.

7
Relationship

Structural Constraints

• The constraint placed on entity types that


participate in a relationship.

• The main type of constraint on a relationship is


Multiplicity.

8
Relationship

Multiplicity

• Single occurrence of entity type may relate to


possible occurrences of an associated entity type
through a particular relationship.

9
Relationship
Multiplicity

One-to-One Relationship

• If for each instance of entity type A there exist a


single instance of entity type B.

• Relationship are abbreviated as 1:1 or One-to-One

Manages
STAFF o BRANCH

10
Relationship
Multiplicity
One-to-One Relationship
Determining the multiplicity

• Consider the relationship Manages, which relates

the Staff and Branch entity types

• A semantic net can be used displays sample

occurrences of the Manages relationship type

11
Relationship
Multiplicity
One-to-One Relationship

12
One-to-One (1:1) Relationships..
➢ By analyzing the semantic net, we can conclude as
follows:

❖ The staffNo SG5 manages branchNo B003 and


staffNo SL21 manages branchNo B005, but
staffNo SG37 does not manage any branch.

❖ In other words, a member of staff can manage


zero or one branch and each branch is managed
by one member of staff.
13
One-to-One (1:1) Relationships
➢ By analyzing the semantic net, we can conclude as
follows:

❖ As there is a maximum of one branch for each


member of staff involved in this relationship and
a maximum of one member of staff for each
branch, we refer to this type of relationship as
one-to-one.

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

❖ For example, if a member of staff oversees a


minimum of zero and a maximum of 100
properties for rent, we can replace the ‘0..*’
with ‘0..100’

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

You might also like