Skip to main content

Command Palette

Search for a command to run...

Importance and types of Relationships in RDBMS

Types of Relationships in RDBMS

Published
3 min read
Importance and types of Relationships in RDBMS
A

I am working as freelancer. I am a experienced full stack web developer. My lovely stack is MERN but I am open for new tech. I love to work with teammates for achieve goals. I love researches to find specific new things.

It is very important to know the importance of relationships in RDBMS and look into the types of relationships in depth along with practical examples.

Importance of Relationships in RDBMS

The concept of relationships in RDBMS is inspired by daily life human relationships. Some people say relationships are good and some say bad based on their experience. Along with there is also a group of people who answer diplomatically telling relationships can sometimes be good or bad, it varies from person to person.

This question is quite controversial, and it is very hard to conclude.

In the same way, if we ask "Are relationships important" anyone they surely will tell "Yes, relationships are important". They might be good or bad, but for humans, relationships play a very important role. In the same way, the relationship data model is also important.

Types of Relationships

We will understand the types of relationships in RDBMS connecting to real-life relationships.

  1. One-to-One Relationship

    Husband-wife is an important example of a one-to-one relationship.

    In the same way in RDBMS we have this concept of a one-to-one relationship where among the two tables, each row of one table has exactly one relationship with only row data of the other table and vice versa.

    We will understand this relationship in another example. Globally we know that the ideal case is that each citizen in a country will be issued one passport. If this data is stored using an RDBMS, there will be two tables namely 'Citizen' and 'Passport'. The relationship between the 'Citizen' and 'Passport' tables is established in such a way that every citizen in the 'Citizen' table will have a unique passport number in the 'Passport' table, and one passport in the 'Passport' table will be associated with only one citizen in the 'Citizen' table. This is called a one-to-one relationship.

    In the same way, each passenger will be provided with one boarding pass. The relationship can be visualized like this.

  2. One-to-many relationship

    For example, a country can have multiple residents. In the country table, each record is associated with multiple records in the resident's table. This type of relationship is called a one-to-many relationship.

    Another example to visualize the relationship is between flight and flight attendants. Each flight can have multiple flight attendants.

  3. Many-to-one Relationship

    If we make the opposite of the above example, it will be a many-to-one relationship.

  4. Many-to-Many Relationship

    The relationship between the students and the courses will be a many-to-many relationship.

    Each student can be part of multiple courses and each course can have multiple students.

    We can also see this type of relationship in applications like Tinder. Let's assume on Tinder there exist two entities males and females. Each male can select multiple females and each female can also select multiple males.