Junction objects for many-to-many relationships
Key Takeaway
To build a many-to-many relationship, create a junction object: a custom object with two master-detail relationships, one to each object you want to connect.
A many-to-many relationship lets each record of one object link to many records of another object, and the other way around. In Salesforce, a junction object is the key to making one. Each junction record works like a connector that ties one record on each side together.
How a junction object creates a many-to-many relationship
The two objects that a junction object connects are its master objects. Each one can be a standard object or a custom object. For example, you can relate a custom Bug object and the standard Case object, so one bug links to many cases and one case links to many bugs.
For example, imagine a recruiting app with a Position object and a Job Posting Site object. A Job Posting junction object sits between them. One position can be posted many times, and one site can have many postings, but each job posting is one position on one site. The two many-to-one relationships on Job Posting together create a many-to-many relationship between Position and Job Posting Site.