DB Lec 15
DB Lec 15
Database Systems
Lecture 15
TYPES OF RELATIONSHIPS
Database Management
Systems
Types of Relationship
• Unary relationship
• Binary relationship
• Ternary relationship
• N-ary relationship
Unary relationship
• An ENTITY TYPE linked with itself, also
called recursive relationship.
• Example Roommate, where STUDENT is
linked with STUDENT
Binary relationship
• A Binary relationship is the one that links two entities
sets e.g. STUDENT-CLASS.
• Relationships can be formally described in an ordered
pair form. Enroll = {(S1001, ART103A), (S1020,
CS201A), (S1002, CSC201A)}
• Entire set is relationship set and each ordered pair is
an instance of the relationship.
Ternary relationship
• A Ternary relationship is the one that
involves three entities e.g. STUDENT-
CLASS-FACULTY.
N-ary relationship
• Most relationships in data model are
binary or at most ternary but we could
define a relationship set linking any
number of entity sets i.e. n-ary
relationship
Relationship Cardinalities
• The cardinality of a relationship is the
number of entities to which another entity
can map under that relationship.
▫ One-to-One mapping
▫ Many-to-One mapping
▫ One-to-Many mapping
▫ Many-to-Many mapping
One-to-One Mapping
• A mapping R from X to Y is one-to-one if
each entity in X is associated with at most
one entity in Y and vice versa.
Many-to-One Mapping
• A mapping R from X to Y is many-to-one if
each entity in X is associated with at most
one entity in Y but each entity in Y is
associated with many entities in X.
One-to-Many Mapping
• A mapping R from X to Y is one-to-many if
each entity in X is associated with many
entities in Y but each entity in Y is
associated with one entity in X.
Many-to-Many Mapping
• A mapping R from X to Y is many-to-many
if each entity from X is associated with
many entities in Y and one entity in Y is
associated with many entities in X.
Choosing between Binary and Ternary
(or Higher-Degree) Relationships
Choosing between Binary and Ternary
(or Higher-Degree) Relationships
• Relationship set of SUPPLY is a set of relationship
instances (s, j, p), where s is a SUPPLIER who is
currently supplying a PART p to a PROJECT j. In general,
a relationship type R of degree n will have n edges in an
ER diagram, one connecting R to each participating
entity type.
Choosing between Binary and Ternary
(or Higher-Degree) Relationships
There are persons other than employees, volunteers, and donors who are of interest
to the organization, so that a person need not belong to any of these three groups.
On the other hand, at a given time a person may belong to two or more of these
groups (for example, employees and donors).
Draw an EER diagram based on the requirements above. Write down assumptions (if
any) you make in your answer.