A relationship is an important part of any Entity relationship diagram as it shows the relation between two different entities. In an n - ary relationship, the n shows the number of entities in the relationship. It can be anything but the most popular relationships are unary, binary and ternary where the number of entities respectively are one, two and three.
More information about Unary, Binary and Ternary relationships is as follows −
When there is a relationship between two entities of the same type, it is known as a unary or recursive relationship. This means that the relationship is between different instances of the same entity type.Some examples of unary relationship can be shown as follows −
A person is only married to one person at a time..Hence, this is a recursive relationship of entity person with itself. This is a one to one recursive relationship as one person is married to one person.
An employee can supervise multiple employees. Hence, this is a recursive relationship of entity employee with itself. This is a 1 to many recursive relationship as one employee supervises many employees.
When there is a relationship between two different entities, it is known as a binary relationship. Some examples of a binary relationship can be shown as follows −
Each employee only has a single ID card. Hence this is a one to one binary relationship where 1 employee has 1 ID card.
Many employees work in a single department. Hence this is a many to one binary relationship where many employees works in one department.
A book can have many authors or multiple authors may have written a single book. So, there is a many to many relationship between books and authors as Many books have many authors.
When there is a relationship between three different entities, it is known as a ternary relationship. An example of a ternary relationship can be shown as follows −
In this example, there is a ternary relationship between Doctor, Patient and Medicine.