Cert++
Close

Junction objects for many-to-many

Key Takeaway

To create 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. Salesforce models it with a junction object that connects the two objects. Each junction record stands for one pairing: one record from each object.

What a junction object is and when to use it

A junction object is a custom object with two master-detail relationships, one to each of the two master objects you want to connect. Each junction record points to one record in each master object, so the junction object has a many-to-one link to each master. Together, those two links create a many-to-many relationship between the two masters.

For example, imagine a Job Posting junction object that connects the Position object and the Job Posting Site object. One position can be posted many times, and one site can have many job postings. But each job posting is always one position on one site. So each Job Posting record is one pairing of a position and a site.

You use a junction object when both sides of a relationship can have many records. The master objects can be standard or custom, but the junction object itself is a custom object.

For example, imagine a custom Bug object and the standard Case object. A bug can relate to many cases, and a case can relate to many bugs. A junction object such as BugCaseAssociation holds each bug-case pair, so each BugCaseAssociation record stands for one bug linked to one case. Here, one master is a custom object (Bug) and the other is a standard object (Case).

Platform Administrator Study Guide

Checklist progress

0/324Learned

Describe the standard object architecture and relationship model (for example: standard object, parent/child, master detail/lookup/junction relationships, record types, Schema Builder)

0/14

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Platform Administrator studiers.