Open In App

Degree of Relations in DBMS

Improve
Improve
Like Article
Like
Save
Share
Report

We are living in a world where every entity has relationships with one other whether a living or non-living being. For example, you are a single entity but you share different relations with your family and friends. Even within a family, you are the son of your father at the same time you are also a sibling of your brother. Similarly, the relationships exist in Database Management (DBMS). In this article, we are going to learn about what is the degree of relationships, and the types of relationships.

Degree of Relationship

In DBMS, a degree of relationship represents the number of entity types that are associated with a relationship. For example, we have two entities, one is a student and the other is a bag and they are connected with the primary key and foreign key. So, here we can see that the degree of relationship is 2 as 2 entities are associating in a relationship.

Types of degree

Now, based on the number of linked entity types, we have 4 types of degrees of relationships.

  1. Unary
  2. Binary
  3. Ternary
  4. N-ary

Let’s discuss them one by one with the help of examples.

Unary (Degree 1)

In this type of relationship, both the associating entity types are the same. So, we can say that unary relationships exist when both entity types are the same and we call them the degree of relationship is 1. In other words, in a relation only one entity set is participating then such type of relationship is known as a unary relationship.

Example: In a particular class, we have many students, there are monitors too. So, here class monitors are also students. Thus, we can say that only students are participating here. So the degree of such type of relationship is 1.

unary

unary

Binary (Degree 2)

In a Binary relationship, there are two types of entity associates. So, we can say that a Binary relationship exists when there are two types of entity and we call them a degree of relationship is 2. Or in other words, in a relation when two entity sets are participating then such type of relationship is known as a binary relationship. This is the most used relationship and one can easily be converted into a relational table. 

Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So, here two entity types are associating we can say it is a binary relationship. Also, one ‘Father’ can have many ‘daughters’ but each ‘daughter’ should belong to only one ‘father. We can say that it is a one-to-many binary relationship.

binary

Binary

Ternary (Degree 3)

In the Ternary relationship, there are three types of entity associates. So, we can say that a Ternary relationship exists when there are three types of entity and we call them a degree of relationship is 3. Since the number of entities increases due to this, it becomes very complex to turn E-R into a relational table. Now let’s understand with the examples.

Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The relationship between these entities is defined as the teacher teaching a particular course, also the teacher teaches a particular class. So, here three entity types are associating we can say it is a ternary relationship.

tarnary

Ternary

N-ary (n Degree)

In the N-ary relationship, there are n types of entity that associates. So, we can say that an N-ary relationship exists when there are n types of entities. There is one limitation of the N-ary relationship, as there are many entities so it is very hard to convert into an entity, rational table. So, this is very uncommon, unlike binary which is very much popular.

Example: We have 5 entities Teacher, Class, Location, Salary, Course. So, here five entity types are associating we can say an n-ary relationship is 5. 

nary

N-ary

Conclusion

In summary, the complexity of the real-world scenario determines the type of relationship (unary, binary, ternary, or n-ary) selected in a database architecture; simpler relationships are favored where feasible. While ternary and n-ary relationships are utilized for more sophisticated interactions, unary and binary relationships are frequently used. The selection should fit the particular requirements and data structure of the application.


Last Updated : 06 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads