You are on page 1of 17

RELATIONSHIPS

Bamweyana Ivan
LSG 2102
Relationships
• Association / Connections between entities
• Participants are entities that participate in a relationship
• Relationships between entities always operate in both
directions, i.e. bidirectional
• Relationship features:
 Cardinality, also called multiplicity (number of occurrences of the
entities participating in a relationship)
 Degree of relationship (how many entities are involved in a
relationship)
Relationship : Cardinality (Multiplicity)
• Cardinality expresses the minimum and maximum
number of entity occurrences associated with one
occurrence of the related entity;
• Minimum cardinality: minimum number of entity instances
that must participate in a relationship
• Maximum cardinality:……..
• Four types:
• One-to-one (1:1)
• One-to-Many (1:M or 1:N)
• Many-to-one (M:1)
• Many-to-Many (N:M or M:N)
One to one (1:1)
• A staff member can be the manager for at most one
cinema and a cinema can have at most one manager

1 1

Staff Manages
Cinema
One to Many (1:N or 1:M)
• Each cinema can have many screens

1 M

Cinema Has Screen


Many to one (M:1 or N:1)
• You can have many subways in a suburb but a subway
can’t be in two suburbs at the same time

M 1

Located
Subway in Suburb
Many to Many (M:M or N:N)
• Each author may have many books and each book may
have several authors

M N

Author Writes
Book
Many to Many (M:N or N:M)
• An actor may be cast in many films and a film may have
more than one actor

M N

Actor Cast Film


Participation
• If every occurrence of “A” needs to participate in the
relationship it is called mandatory participation.
• If not every occurrence of “B”… it is called optional
participation.

A Relationship
B
Relationships: Participation
• Optional (partial) participation
• One entity occurrence does not require corresponding entity
occurrence in particular relationship
• Participation represents in a single line
• Mandatory (total) participation
• One entity occurrence requires corresponding entity occurrence in
particular relationship
• Participation represented in a double line
• Entity Relationship Diagram
Relationships: Degree
• Degree of relationship indicates the number of entities or
participants associated with a relationship
• Three types:
 Unary (association is maintained within single entity) – see
recursive relationship
 Binary (two entities are associated)
 Ternary (three entities are associated)
Recursive Relationship
• The entity has a relationship with itself.
• The same entity participates more than once in a relationship
• E.g. an employee reports to an employee

1
Employee Reports
1
Example: Ternary
Multiple Relationships; same entities
• A pair of entities can have more than one relationship
linking them
• There may be different cardinalities and different
participation for each relationships
Alternate Relationship Denotations
• You will see variations on the ERD style used

• You may come across other tools, too


• e.g. UML (Unified Modelling Language)
Home work 1
• Identify type of cardinality constraint
(Relationship) for following:
• Many facilities belong to a forest. Each
facility belong to one forest.
• A manager manages 1 forest. Each forest
has 1 manager.
• A river supplies water to many facilities. A
facility gets water from many rivers.
Home work 2
• A staff member may be a manager at one cinema but not
all staff will need to manage a cinema (projectionist, ticket
salesperson, etc…) while a cinema must have at most
one cinema manager
• Sketch the above relationship

You might also like