Deep dive into Junction object – Create many to many relationship in Salesforce

In Interview for the salesforce technology, one common question asked is how to implement the many to many relationship. If we answer that using junction object then there next question comes how ? explain it and after that, next question will be what happen if i delete one master record ?

So, in this article i will first show you that how to create custom objects, how to relate them and what will happen if we delete master or child?

here i am going to assume that we want to relate A and B. Let us assume that we have two custom object – A and B.
To provide the many to many relationship between A and B, we will need to create one more object let’s say it would be C, it will be called as junction object.

Please try your self and come back with some logical questions.

Few important points (Interview Questions of salesforce ):

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

Cheers!!

Leave a Comment

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

Select Language »