function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mamidi maheshmamidi mahesh 

why cant we create many to many relationship on lookup

Hi all,
There are two objects A, B, i have taken one intermediate custom object Jobject (Junction object). I have created A to Jobject lookup reationship and B to Jobject lookup realationship. now my question is that is it many to many relationship. if it is not many to many relationship then why. and why cant we create many to many relationship using lookup relationship. please explain about it.
Sagar PareekSagar Pareek
Here are my two cents:

 

Use lookup to just link two standard or custom objects.
Use master-detail when you want you master record to control your detail object. For e.g. if quotes is a detail under opportunity, then if you delete an opportunity, the related quotes also would be deleted.
Use master-detail even when you want to create many-many relationships. Here you would be creating a junction object, which would have two master-detail relationships.

 
Mukesh Kumar 107Mukesh Kumar 107
Though you can use Lookup Relationship for creating a Many-To-Many relationship, but, it will not support entire feature of Many-To-Many concept. In other words, using Master-Detail Relationship for creating Many-To-Many Relationship gives you an ideal feature of Many-To-Many. Here are the features which you will not get with lookup relaionship.

1. We talk about 'Junction' object, whose identify and existence depends on Master record. Meaning Master deleted should trigger details to be deleted. From Application perspective you do not need any visibility of Junction Object. In other words, application should magically connect Object A with Object B. That is it. In that sense Master-Detail works best.
2. You loose agreegate functionality, if you need one on Detail Object

If these features are not required or adjusted somehow by your custom code, then both options will work. But, Master-Detail solution is always the ideal solution.