0% found this document useful (0 votes)
12 views19 pages

DB Lec 15

DATABASE

Uploaded by

70131299
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views19 pages

DB Lec 15

DATABASE

Uploaded by

70131299
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

1

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

• Three binary relationship types CAN_SUPPLY,


USES, and SUPPLIES. Suppose that
• CAN_SUPPLY, between SUPPLIER and PART,
includes an instance (s, p) whenever supplier s
can supply part p (to any project);
• USES, between PROJECT and PART, includes
an instance (j, p) whenever project j uses part
p;
• SUPPLIES, between SUPPLIER and PROJECT,
includes an instance (s, j) whenever supplier s
supplies some part to project j
Choosing between Binary and Ternary
(or Higher-Degree) Relationships
Choosing between Binary and Ternary
(or Higher-Degree) Relationships
• Some database design tools are based on variations
of the ER model that permit only binary
relationships. In this case, a ternary relationship
such as SUPPLY must be represented as a weak
entity type, with no partial key and with three
identifying relationships.
Another example of ternary versus
binary relationship types.
A weak entity type INTERVIEW with a
ternary identifying relationship type.
An organization depends on a number of different types of persons for its successful
operation. The organization is interested in the following attributes for all of these
persons: SSN, Name, Address, and Telephone. A person may have multiple
telephone numbers. Three types of persons are of greatest interest: employees,
volunteers, and donors. Employees only have a Date Hired attribute, and volunteers
only have a Skill attribute. Donors only have a relationship (named Donates) with an
Item that has number and name. A donor must have donated one or more items, and
an item may have no donors, or one donor.

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.

You might also like