Home SALESFORCEConfiguration How to create a Many to Many Relationship in Salesforce

How to create a Many to Many Relationship in Salesforce

Junction Object:
A custom object with two master-detail relationships. Using a custom junction object, you can model a “many-to-many” relationship between two objects.
For Example:
Junction objects are used to create many to many relationships between two objects. If you take the Recruiting Application example, you can see that a Position can be linked to many Candidates, and a Candidate can apply for different Positions. To create this data model you need a third object called “Job Application” that links to Application and Postions.
many-to-many-relationshipSo need create a master details field for both Position and Candidate object on the “Job Application” object. This will establish many to many relationship between Position and Candidate via the “Job Application” object known as the junction object.More details: https://help.salesforce.com/HTViewHelpDoc?id=relationships_manytomany.htm

So here totaly 3 custom objects as per the Recruiting Application:
1) Position – (P) – Primary master record
2) Candidate – (C) – Secondary master record
3) Job Application (JA) – Junction Object

Notes:
-One Object can have only two Master-Detail relationships (i.e Job Application object).
-If we delete record P (First Master detail relationship is always primary)  – then child record JA will be deleted.
-If we delete record C then in this case also child record JA will be deleted.
-If we delete record JA then only JA will be deleted, master record will not be deleted.
-If child JA has two Master record P and C, Where P is primary relation then Child record JA will inherit the look and feel of Parent object P.

You may also like

Leave a Comment