Explain the types of relationships in database

1) One-to-one: One to one is implemented using single table by establishing relationship between same type of columns in a table.

2) One-to-many: Implemented using two tables with primary key and foreign key relationships.

3) Many-to-many: Implemented using a junction table. The keys from both the tables form composite primary key of the junction table.


There are four relationships in database.

- One to One: One entity is associated with another entity. For Ex: Each employee is associated with one department

- One to Many: One entity is associated with many other entities. For Ex: A company is associated with all working employees in one branch/office/country.

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

- Many to Many: Many entities are associated with many other entities. 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.


No comments:

Post a Comment

The advantages of Outsourcing Web Development Services

In the present digital world, acquiring a solid web presence is essential for companies to flourish. A well designed site is much much more ...