+ Start a Discussion

Junction objects

Guyz...I am fed up reading junction objects, some say that it is only with two master details relation ships, some say that it can be with two lookup relationships also and some say it can be a combination of both. But at the end I am not clear which can be called as the junction object. Can if someone really explain this with a small example, a billion thanks. 
Any of those can be called a junction object.  A junction object simply forms a many to many relationship between two objects.  I would say 99% of the time you would make that a master-detail for both objects in the junction.  However there are always exceptions to the rules.  For example, if your junction object had additional information that you wanted to keep if one of the parents were deleted then you would not want to make that a master-detail.


Master-Detail for both:
  • If you look at the CaseTeamMember or AccountTeamMember object, this is a simple junction object between the Case/Account and a User.  It also has some additional information on it such as the type the member is.  In this case it does not make sense to keep the member object around if either the Case/Account or the User are deleted and creating one without either serves no purpose.  So making them both master-detail makes the most sense
Lookup for both / some:
  • In my opinion this is the toughest to find a good use for.  Lets say you had a Case and a Group object and you wanted to pair them together with a Contact to make a CaseGroupMember junction object.  While it may make some sense to make all of the master-detail, lets say (for argument sake) that you wanted to keep the CaseGroupMember object around for forensic work or you have some process that you then alert your Contact or Case owner if the Group is deleted that they need to do something.  In this case you'd want to make some of these a lookup or all of them a look up so that your data hangs around.

That last example is a really weak one which is why I say that 99% of the time you want them to be master-detail for all members.