10

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?

8

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.

  • 2
    Security is definitely important; the detail object will inherit it's parent's security which I think is useful, probably correct most of the time, and simplifies administration. – Mike Chale Mar 29 '13 at 12:29
  • 2
    Also, Master/Detail relationships can ensure that the junction objects are automatically deleted when one of the parent records is deleted. Otherwise you will need to make sure you clean up any orphaned MtM records every time one of the parents is deleted. – Jeremy Nottingham Mar 29 '13 at 14:25
  • From what I've read, special report types are also created when the master-detail relationship type is used in a many-to-many relationship. Thanks @anup! – Wes Nolte Apr 1 '13 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.