[WEBINAR] The New Normal: Dealing with the Reality of an Unsecure World

Many-to-Many Relationship

Definition - What does Many-to-Many Relationship mean?

A many-to-many relationship refers to a relationship between tables in a database when a parent row in one table contains several child rows in the second table, and vice versa. Many-to-many relationships are often tricky to represent.

The many-to-many relationship is usually a mirror of the real-life relationship between the objects the two tables represent.

Techopedia explains Many-to-Many Relationship

A database used by a school application can be taken as an example. Two of the tables it contains are "Student" and "Subject." In real life, a student will take several subjects simultaneously, while a subject will be studied by several students at a time. This is a many-to-many relationship.

In a database, such a relationship has to be broken down into intermediary tables. In our school example, this may take the form of a third table that contains the columns “Student_ID”, “Subject_ID”, “Semester” and “Year”. For each student who takes a certain subject in a certain semester in a certain year, a row can be entered into this table. The Student_ID is read from the Student master table, while the Subject_ID is read from the Subject master table. In this way, many students can be related to many subjects.

Another example can be a relationship between employees and departments. Each department can have any number of employees working on a specific task. Similarly, an employee can also work for multiple departments at one time. Therefore, any number of departments or employees can simultaneously be linked to each other by creating an intermediary table that links them using the Employee_ID and the Department_ID.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.