Creating a Many-to-Many Relationship
Creating a Many-to-Many Relationship - master-detail relationships are used to model many-to-many relationships between any two objects. A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa. When modelling a many-to-many relationship, a junction object is used to connect the two objects to relate to each other.
Using a custom junction object, a “many-to-many” relationship can be modelled between two objects.
Creating the many-to-many relationship consists of:
- Creating the junction object.
- Creating the two master-detail relationships.
- Customizing the related lists on the page layouts of the two master objects.
- Customizing reports to maximize the effectiveness of the many-to-many relationship.
The first master-detail relationship you create on your junction object becomes the primary relationship, and so the junction object acquires Look and Feel, Record Ownership and the Division, if Divisions used in the organisation form the primary relationship.
The second master-detail relationship you create on your junction object becomes the secondary relationship. If you delete the primary master-detail relationship or convert it to a lookup relationship, the secondary master object becomes primary.
- Create a Junction object.
- Relate to primary object in master detail relationship
- Relate to the secondary object in the Master Detail relationship.
- Customise both Primary and Secondary objects Layouts to display the junction object’s and other objects fields – edit related listsàJunction Object section in layout editor.
- Fields from other objects in the Masters are available in the record’s detail page under related ListsàJunction Object’s section i.e. junction objects Section – details from both the junction object and the other master are available here. But in junction object the master objects fields are directly available as fields (the Master Detail relationship itself is created by inheriting the field of Master as fields for the Detail object)