Why does the documentation stipulate that a many-to-many object relationship requires two master-detail relationships?

In theory you can model a many-to-many relationship using lookup fields exclusively or in combination with a master-detail field. However the documentation only mentions master-detail fields.

What are the reasons for this?


There are a number of considerations when building out many to many relationship in Salesforce:

  1. Querying the objects in your code
  2. Look and feel of the linked objects.
  3. Security and sharing settings of the objects involved in the relationship.

The reason Salesforce recommends building a many-to-many relationship can be found in this section of the documentation:

The first master-detail relationship you create on your junction object becomes the primary relationship. This affects the following for the junction object records:

Look and feel: The junction object’s detail and edit pages use the color and any associated icon of the primary master object.

Record ownership: The junction object records inherit the value of the Owner field from their associated primary master record. Because objects on the detail side of a relationship do not have a visible Owner field, this is only relevant if you later delete both master-detail relationships on your junction object.

Division: If your organization uses divisions to segment data, the junction object records inherit their division from their associated primary master record. Similar to the record ownership, this is only relevant if you later delete both master-detail relationships.

Even though (in theory) you can create many to many relationship using lookup, some of these factors mentioned above should be considered when building out this relationship, which are automatically facilitated by the master detail relationship, hence the recommendation I think.

Source : Link , Question Author : Wes Nolte , Answer Author : Community

Leave a Comment