Degree of Relationship in DBMS-Unary, Binary, Ternary, and N-ary (n degree) Relationship
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
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.
The above relationship means that a person lives with another.
Binary relationships exist between the instances of two entity types. Different types of relationship are as follow.
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”.
Above image means that one country has one president. Similarly, one president is of only one country.
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.
The above relationship means the one college can have many departments but one department is part of only one college.
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”.
The above relationship means that one reader may read many books and one book may be read by many readers.
Ternary relationship exists among the instance of three entity types.
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.