Lesson 9 of 18 · 5–7 minutes
Many-to-Many Relationships and Junction Objects
A single lookup allows one parent per field. A junction represents each pairing when both sides can have many partners.
Learning sequence · data model first, security layers next
- What CRM and Salesforce Do
- The Salesforce Ecosystem and Major Clouds
- Org, App, Object, Field, and Record
- Standard and Custom Objects
- Common Standard Objects
- Field Types and Data Quality
- Objects, Fields & Records
- Lookup vs Master-Detail
- Many-to-Many Relationships and Junction Objects
- Profiles, Permission Sets & Object Access
- Field-Level Security
- OWD and Least-Privilege Record Access
- Opening Access: Role Hierarchy, Sharing Rules, Public Groups & Apex Sharing
- Apex First Steps
- Variables and Collections
- SOQL and DML Basics
- Why Asynchronous Apex Exists
- REST Callout Introduction
Your focus
Prepare for Senior / Lead Roles
CHECKPOINT · Checkpoint • Design • Troubleshoot
- Challenge inherited sharing and retention assumptions; consider growth and parent concentration.
Learning objective
Represent a many-to-many association as a record with its own attributes.
Before you start
Lookup vs master-detail, especially deletion and inherited access.
Real-world scenario
A training provider runs compliance courses for customer staff. One Enrollment stores one student’s participation in one course. If repeats are allowed, define whether the business key includes a course session or attempt rather than forbidding every repeated student–course pair.
The concept
A Student can take many Courses; a Course can have many Students. Enrollment records each student–course pairing, with enrollment date and completion status. Those attributes describe the association, not either parent. The standard Salesforce junction pattern uses a custom object with two master-detail relationships. If independent retention or ownership is required, evaluate an association object with lookups instead; it has different sharing and roll-up behavior.
For two master-detail fields, access depends on both parent records and their relationship sharing settings. Deleting either parent can delete Enrollment records. Decide how historical completion evidence is retained, how duplicates are detected and which reports should count enrollments versus students.
Enrollment is the junction. Each Enrollment references exactly one Student and one Course; each parent can have many Enrollments.
1.Student
A person taking training.
2.Enrollment — junction object
Participation date, status and attempt.
3.Course
The training offering.
- Student connects to Enrollment — junction object: one student → many enrollments
- Course connects to Enrollment — junction object: one course → many enrollments
Common mistake
Storing a comma-separated course list on Student loses attributes, referential integrity and useful reporting. Also avoid assuming access to just one master always exposes the junction.
Interview angle
“Where does a course completion date belong?” On Enrollment, because one student can finish different courses on different dates. Explain the consequences if a parent is deleted.
Pause and apply
Draw two students taking two courses. How many Enrollment records represent all four pairings? Where would a second attempt be distinguished?
Official references
- Trailhead: Create a Junction Object (opens in a new tab)
- Salesforce Help: Considerations for Object Relationships (opens in a new tab)
Reviewed 2026-09-22. Examples are illustrative; no code is executed here.
Key takeaways
- The association is a business record, not just a connector.
- Choose each relationship deliberately; two masters couple access and deletion.
- Load parents before associations and define a duplicate/retention policy.
Practice next
No linked assessment is available for this lesson. Use the pause-and-apply question to check your reasoning.
Reading these lessons does not yet save completion. Challenge results continue to provide assessment evidence.