Junction Object or Many to Many Relationship in SFDC

There is no out of box relationship present in SFDC i.e. Many to Many in nature, So to have a many to many relationship in SFDC a JUNCTION OBJECT is required.

A junction object joins the two objects with two master detail relationship. Junction object is always on the detail side of the object.

A1__c M : 1 Junction (J__c) 1 : M A2__c

This way junction object creates Many to Many relationship between A1__c and A2__c. (DEV 401 Question)

One example of many to many relationship among standard objects is Case and Solution. One case can have many solution attached to it and one solution can be used in resolving many cases.

Q. What is a Junction?
A. Object used for creating many-to-many(m-m) relationship between 2 objects. Junction object will have 2 master-detail fields.
Example: To create m-m relationship between object A1__c and A2__c, create a junction object J__c with Master detail field corresponding to A1__c and A2__c.

Few important points (Interview Questions of salesforce ):

  1. One Object can have only two Master-Detail relationships.
  2. If we delete record A (First Master detail relationship is always primary) – then child record c will be deleted.
  3. If we delete record B then in this case also child record C will be deleted.
  4. If we delete record c then only C will be deleted , master record will not be deleted.

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 15x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply

Your email address will not be published. Required fields are marked *