12 Mar 2016

Many-To-Mmany Relationship

Many to Many Relation or Junction Object:

Junction Object:

A custom object with two master-detail relationships. Using a custom junction object, you can model a “many-to-many” relationship between two objects. For example, you may have a custom object called “Bug” that relates to the standard case object such that a bug could be related to multiple cases and a case could also be related to multiple bugs.

Many to many relationships are established by creating a linking object.  The linking object must have a relationship to each of the objects it is linking together.  For instance,In a custom application, two custom objects Job Posting and Applicant require a many to many relationship.  To do this, create an object Job Posting Applicant Link (the name is not important), and create lookup (or master-detail) relationships on this object to both "Job Posting and Applicant.  If master-detail relationships are used, when either a Job Posting or an Applicant is deleted, all related "Job Posting Applicant Linkrecords are deleted.The related lists on Applicant and Job Posting can be configured to displayed the corresponding information from each object through the linking object.
The only way to create a seamless (no visible linking object to the end user) many to many relationship is to use custom code.