function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
:) :) :) :) :):) :) :) :) :) 

Salesforce Object Relationships

Hi All,

I have knowledge of different salesforce object relationships but can anyone give me better understanding with practical example among these different relationships. I might be wrong but I think we can also create junction object with lookup or master-detail but when should I use lookup and when should I use Master detail junction object? 
  1. Lookup
  2. Master-Detail
  3. Self (Hierarchical)
  4. Junction object using Lookup
  5. Junction object using Master-Detail.
Andy BoettcherAndy Boettcher
Master/Detail and Lookup are very close to each other now - with the addition of (for instance) reparenting on M/D and cascading delete on Lookups.

The biggest difference IMHO is the ability to do Rollup calculations on a M/D relationship.  M/D is the only way to do it declaratively - unless you implement something like Rollup Helper.
Hi there, I think this documentation is worth reading through for a better understanding of Salesforce's object relationships: (

There are some especially good points made about the technical ramifications of lookup vs master-detail relationship fields.

As for examples:

1. In a lookup relationship the child may or may not have a parent. A real world example of this is a dog may have an owner or it might be a stray.
2. A detail object record requires a parent record, but not the other way around. A real world example of this is a shadow must be cast from an object, but it's possible for an object to not have a shadow at high noon or in the dark.
3. It's possible for an organization to have a parent organization. For example, Google is now technically one company of many under Alphabet, the parent organization.
4. I wouldn't recommend creating a junction object via lookup relationships. Master-detail relationships are better suited for junction objects to prevent orphan records--by definition a junction object record should relate its two parents so neither should be allowed to be blank and lookup fields, unlike master-detail fields, are not required by default on the child object.
5. A job posting may have many candidates that apply and likewise the same candidate may apply to several job postings. In this case a junction object could be created using master-detail fields to create a many-to-many relationship between job postings and candidates.
karunakarreddy bade 8karunakarreddy bade 8

Master-Detail and Lookup are very close to each other.
The biggest difference in the master-detail and lookup the Roll up summary is available in master-detail only
the master-detail is the best one  to implement something like Roll up summary's

Kaushik Kyada 12Kaushik Kyada 12
Suppose i have created junction object using master-details and if i am going to delete one of master record then what will happen?
Is it give me error or it will delete junction object record regardless of second master in still there?
How deletion will take place here?