Home | Computer | Degree of Relationship in DBMS-Unary, Binary, Ternary, and N-ary (n degree) Relationship

Degree of Relationship in DBMS-Unary, Binary, Ternary, and N-ary (n degree) Relationship

August 31, 2022

A relationship may consist of many entities. The number of entities in a relationship is called the degree of relationship. The relationship of degree 2 is most common and is also called a binary relationship. The types of relationships with respect degree are as follows:

  • Unary relationship
  • Binary relationship
  • Ternary relationship

Unary Relationship

The unary relationship is a type of relationship that is established between the instances of the same entity type. This is also known as a recursive relationship.

Example

image showing the Unary Relationship

The above relationship means that a person lives with another.

Binary Relationship

Binary relationships exist between the instances of two entity types. Different types of relationship are as follow.

One-to-One relationship

This type of relationship is used when “for each instance in the first entity class, there is only one instance in the second entity class and for each instance in the second entity class, there is only one instance in the first entity class”.

Example

image showing the One-to-One Relationship

Above image means that one country has one president. Similarly, one president is of only one country.

One-to-Many Relationship

This type of relationship is used when “for each instance in first entity class, there can be many instances in the second entity class and for each instance in second entity class, there is only one instance in the first entity class.

image showing the One-to-Many Relationship

The above relationship means the one college can have many departments but one department is part of only one college.

Many-to-Many relationship

This kind of relationship is used when “for each instance in first class, there can be multiple instances in the second class and for each instance of the second class, there can be several instances in the first class”.

image showing the Many-to-Many Relationship

The above relationship means that one reader may read many books and one book may be read by many readers.

Ternary Relationship

Ternary relationship exists among the instance of three entity types.

image showing the Ternary Relationship

The above relationship means that one or many analysts with one or many programmers work on one or many projects.

N-ary (n degree)

In the N-ARY relationship, there are n kinds of entities that associate. So, we can state that an N-ARY relationship exists when there are N kinds of entities. There is only one limitation of the N -ARY relationship, as there are too many entities so it is difficult to convert into an entity table. So, this type of relationship is very rare, unlike binary which is widely used.

Example

image showing the N-ary Relationship