Different types of relationship in Database

Different types of relationship in Database

A Database is an organized collection of data. Simply, it is a structured set of data held in a computer, especially one that is accessible in various ways. It is a collection of information that is organized so that it can be easily accessed, managed and updated.

There are four relationships in the database.

(1) One to One: One entity is associated with another entity. In the absence of such a rule, you can usually combine both tables into one table without breaking any normalization rules. For Ex: Each employee is associated with one department. A one-to-one relationship can be used for security purposes, to divide a large table, and various other specific purposes.

(2) One to Many: One entity is associated with many other entities. The primary key table contains only one record that relates to none, one, or many records in the related table. For Ex: A company is associated with all working employees in one branch/office/country.

(3) Many to One: Many entities are associated with only one entity. For Ex: Many employees are associated with one project.

(4) Many to Many: Many entities are associated with many other entities. Each record in both tables can relate to any number of records (or no records) in the other table. For Ex: In a company, many employees are associated with multiple projects (completed/existing), and at the same time, projects are associated with multiple employees.

Share This Post