Types of Database Relationships

Jeganathan Suvarna
2 min readMar 24, 2021

A relational database is a type of database that stores and provides access to data points that are related to one another. Relational databases are based on the relational model, an intuitive, straightforward way of representing data in tables. In a relational database, each row in the table is a record with a unique ID called the key. The columns of the table hold attributes of the data, and each record usually has a value for each attribute, making it easy to establish the relationships among data points. Database relationships are the backbone of all relational databases. A relationship is established between two database tables when one table uses a foreign key that references the primary key of another table

There are three specific types of relationships that can exist between a pair of tables:

1. One to One

2. One to Many

3. Many to Many

One to One Relationship (1:1)

It is used to create a relationship between two tables in which a single row of the first table can only be related to one and only one record of a second table. Similarly, the row of a second table can also be related to anyone row of the first table.

Eg: One person has one passport, and the passport can only be used by one person

One to Many Relationship (1:M)

A one-to-many relationship allows a single record in one table to be related to multiple records in another table.

Eg: A single customer can purchase multiple orders, but a single order could not be linked to multiple customers

Many to Many Relationship (M:n)

This is a complex relationship in which many records in a table can link to many records in another table

Eg: order can contain multiple products, and a product could be linked to multiple orders

importance of database Relationship

Establishing consistent relationships between database tables helps ensure data integrity, contributing to database normalization

These are the basic things you should know about Relationship

--

--