You are on page 1of 3

DATABASE

TYPES OF RELATIONSHIPS

MARIA NIAN NIÑA B. TORRES- SAINT IGNATIUS OF LOYOLA


TYPES OF RELATIONSHIPS
A relationship represents the connection of one entity to another. There are three types of
relationships possible based on cardinality or the number of records that can be related to
each other.

In a one-to-one relationship, one record in the first table can be related to only one record
in the second table; a country, for instance can have only one capital. In the following
illustration, each record in the table countries has only one partner record in the table
capitals and vice versa.

COUNTRY CAPITAL

A one-to-many relationship means that one record in the first table can be related to
many records in the second table, but records in the second table can be related to only
one record in the first table. As can be seen in the following illustration, one subject can
have many clauses.

There are also times when a record in the first table can be related to many records in the
second table, and each record in the second table can also be related to many records in
the first table. This is called many-to-many relationship. A student enrolls in many
subjects, and a subject can be enrolled into by many students. In the example below, the
table enroll shows this relationship.

PAGE 1
Student Number is a good primary key for the table student because each student is
assigned a unique number as shown in the following list.

A primary key should always have a valid value; it cannot have a null value.

A field is a piece of information in a table.

The subject code in the table Class alone may not be a good choice as a primary
key because a subject can have several classes with different schedules. For
instance, the subject ACCMANA in the illustration below appears in three records.

Combining the subject code with section identifies a class uniquely and the result
is a composite key.

PAGE 2

You might also like