In the E-R diagram, a relationship is connection between two or more entities. The relationship is shown as a diamond shape in the E-R diagram. The degree of relationship is the number of entities linked together in a single relationship.

In this article, we will explore different types of common relationship degrees in DBMS.

Common Relationship Degrees

Here is a list of relationship degrees.

  1. Unary relationship (Degree 1)
  2. Binary relationship (Degree 2)
  3. Ternary relationship (Degree 3)
  4. N-ary relationship (Degree N)

Unary Relationship (Degree 1)

A unary relationship or recursive relationship of degree 1 exists when an entity is related to itself.

Figure 1: Employee mentors another Employee is a Unary Relationship
Figure 1: Employee mentors another Employee is a Unary Relationship

For example,

An employee Ravi mentors another employee Amit is a Unary relationship where both entity belong to same entity set – Employee.

Binary Relationship (Degree 2)

A binary relationship involves two different entity sets. This is the most common type of relationship in database. The degree of binary relationship is 2.

For example,

Student enrolls in Course.

Figure 2: A binary relationship between Student entity and Course entity. The Enrolls is the relationship name.
Figure 2: A binary relationship between Student entity and Course entity. The Enrolls is the relationship name.

Student and Course are the two entities involved in this binary relationship. The Enrolls is the name of the relationship.

Each student can enroll into multiple courses and each course have multiple students. This is cardinality of the relationship. We shall discuss this topic in another article.

There are several other real-life examples.

  • Employee works for a Department.
  • Doctor treats Patient.
  • Teacher teaches Students.

Sometimes, the relationship is more complex and have more than two entities. We shall see these in the next sections.

Ternary Relationship (Degree 3)

A ternary relationship involves three entities simultaneously. The degree of ternary relationship is 3.

For example,

Professor teaches physics Course to Student.

Here three entities are involved.

  • Professor
  • Course
  • Student

The relationship is ternary relationship called Teaches.

Figure 3 - A Ternary relationship between Professor, Student, and Course. The name of the relationship is Teaches.
Figure 3 – A Ternary relationship between Professor, Student, and Course. The name of the relationship is Teaches.

What happens when there are more than three entities in a relationship. Its called a N-ary relationship.

N-ary Relationship (Degree 4 or higher)

Definition: An N-ary relationship is a relationship involving N entity sets, where N >= 4.

Technically, ternary relationship is also N-ary relationship with N = 3.

Here are some examples,

  • 5 entities -> 5-ary relationship
  • 6 entities -> 6-art relationship
  • 7 entities -> 7-ary relationship

For example, the relationship between Student, Teacher, Course, and Department is a 4-ary relationship. If the relationship is Assignment. Then we could describe it as

“A Teacher gives an assignment to a Student studying a Course in a Department.”

or more precisely.

“The teacher gives an assignment to a student studying Physics in Physics department“.

Figure 4 - N-ary relationship between 4 entities - Teacher, Student, Course, and Department where N is 4. The relationship name is Assignment.
Figure 4 – N-ary relationship between 4 entities – Teacher, Student, Course, and Department where N is 4. The relationship name is Assignment.

The degree of N-ary relationship is N, because it is the participating number of entity sets.

Summary

The degree of a relationship describe the number of participating entity sets. There are four types of relationships based on the degrees in DBMS.

Unary where a single entity set is related to itself.

Binary relationship with degree 2 where two different entity set are related to each other.

Ternary relationship has a degree of 3 where three separate entity sets are connected.

N-ary relationship with degree N, have 4 or more entity sets related to each other. Students often confused about the Degree vs Cardinality.

The cardinality is number of instances related between entity sets. Degree is number of entity sets itself participating in the relationship.