Types of Relationships in DBMS

Types of Relationships in DBMS

 

In this article, we will learn about different types of relationships in DBMS.

  • A relationship represents the association between two are more entities
  • The relationship also shows the different entity sets that are participating in a relationship, these relationships very much useful analyzing the design process of the system
  • There are 5 types of relationships
    • Unary Relationship
    • Binary Relationship
    • n-ary Relationship
    • Recursive Relationship
    • Ternary Relationship
Types of Relationships

Unary relationship

When there is only one entity set participating in a relationship then such type of relationship is called unary relationship

Example of unary relationship

For example, a person has only one passport and only one passport is given to only one person and hence unary relationship is observed

Binary relationship

When there are exactly two  entity sets participating in a relationship then such type of relationship is called binary relationship

Example of binary relationship

For example, a teacher  teaches a  subject here 2  entities are teacher and subject for the   relationship  teacher teaches subject

N-ary relationship

When a large number of entity sets  are participating in a relationship,  then such type of relationship is  called an n-ary relationship

Example of n-ary Relationship

In the real world, a patient goes to a doctor  and doctor prescribes the medicine and diagnosis  to the patient, four entities Doctor, patient and medicine, diagnostics  are involved in the relationship “prescribes” 

n-ary Relationships

Recursive relationship

A Recursive relationship is nothing but, simply an entity is having a relationship with self

Example of recursive Relationship
    • The person who is a supervisor for many other employees also come under employees category
    • Student can be a class monitor and handle other students but a person who is working as a class leader is itself a student of the class and hence a class monitor has a recursive relationship of entity student 
Recursive Relationship in DBMS

Ternary relationship

When there are exactly three entity sets participating in a relationship then such type of relationship is called ternary relationship

Example of Ternary Relationship

In the real world, a patient goes to a doctor  and doctor prescribes the medicine to the patient, three entities Doctor, patient and medicine are involved in the relationship “prescribes”

Ternary Relationships in DBMS
Learn more about Relationships in DBMS.