+ Start a Discussion
elghoul_girlelghoul_girl 

Difference between Lookup Relationship and Master-Detail RelationShip

Hello Everybody,

 

   I am new in SalesForce. I don't understand what is the difference between the lookup and master-details relationships. Both are one to many relation ship.... and I can't imagine while developing when I should use each.. So, please advice

 

Thank you,

    Sally

EnthEnth

There's fundamental differences in the behaviour and record sharing that you need to read up on. The following is purely a summary from memory and may not be 100% accurate, please refer to the salesforce help for a full explanation.

 

The key difference is master-detail has a direct dependency between the objects:

 

  • You cannot have a detail record without a master.
  • The detail record inherits sharing rules from the master.
  • You cannot update the relationship to the master in a master-detail relationship.
  • The number of master-detail relationships you can use are limited.
  • You cannot set profile object permissions for a detail record
  • Master-detail relationships are automatically included in report record types 

 

 

When you delete the master it will cascade delete all detail records relating to that master. A typical use of a Master-Detail would be the classic Sales Order and Sales Order Items objects. 

 

 

  • Lookups are generally for use where you may or may need to have a relationship between two objects (but not always).
  • Lookups are generally used to reference commonly shared data, such as reference data.
  • Lookups are used to link two objects together when you don't want the behaviour of the master-detail - particularly around sharing rules, profile permissions and cascade delete.
  • Lookups are used when you need to relate multiple 'parents' to the detail record.

 

 

You can change between a master-detail and a lookup after you create the field. My recommendation is always start with a Lookup relationship and then if you decide you need the features of a master-detail change it. If the detail object has it's own tab then you probably want to use a lookup not a master-detail.

 

HTH

 

KmoffatKmoffat

You mention once you create a lookup relationship you can change it to a master-detail relationship.  How do you actually do this?

EnthEnth
Click Edit on the field, and then click the Change Type button. You will be warned if not all records have parent values populated (if going to a Master-Detail), in which case you'll need to fix your data first.
raghava arigelaraghava arigela

Yeah you can do that by editting the custom field i.e, related to lookup relation and then change the datatype to master-detail relationship.

 

Raghavendra Reddy .DRaghavendra Reddy .D

Loookup :                                                                    Master :

Loosely coupled                                                       Tightly coupled
Max number of lookup is 25                                      Max number of master is 2
Not a mandatory                                                        Mandatory
Once value is assigned can be changed                   Cannot be changed
Partent delete child cannot delete                              parent delete child also delete
  cannot on lookup                                                        Roll up can be made on master-detail
Siva reddy 122Siva reddy 122

Hi , am new to salesforce technology... As raghavendra reddy .d mentioned clearly i have a doubt regarding 

Not a mandatory , mandatory...

can u plz clear about it

Archana BattaArchana Batta
Hi Siva,

In Lookup, it's not mandatory to specify which is the parent record to your child. Where as in Master-detail, we have to specify the parent record for the child record. That's what Not a mandatory and mandatory means in this case.

Regards,
Archana.
Adriano de andrade silvaAdriano de andrade silva
I'm updating the comparison from Raghavendra Reddy. Maybe in 2015 was different, but today you can change the parent value on master-detail relationship.
It can be done choosing the option "Reparentable Master Detail" on creation of the master-detail relationship.
 
R JeswanthR Jeswanth
Lookup Relationship: -
This type of relationship links two objects together. This is loosely bounded. We can use lookup when objects are only related in some cases. Objects in lookup relationship usually work as standard alone objects.

Master-Detail Relationship: -
This is Parent (Master) Child (Detail) relationship in which the master object controls certain behaviors of the detail object. This is tightly bounded.
For Ex – In program Event Management with a Master-Detail between Events and Budget, you can delete the Event and the entire related Budget. 



 
Christian ClausChristian Claus
I would like to know how to distinguish between master detail and lookup relationships in Apex.
For example, how do I determine if a relationship is a lookup relationship?
Swapnil HudeSwapnil Hude
Master-detail relationship

1)in m-d relationship field value is mandatory
2) here parent record is deleted automatically child records is deleted
3) an object is allowed only 2 m-d relationship fields
4) if we give any rules to parent that rules automatically goes to the child. Child does not conatin any seperate rules.
5)we can directly conert m-d relationship to lookup relationship
6) if we give a value to m-d relationship field that value doesnot changed.

*m-d=Master-detail

Lookup relationship

1)in lookup relationship field value is not mandatory
2) here parent record is deleted automatically child records are not deleted
3) an object is allowed only 25  relationship fields
4) here parent rules and child rules are may be same or not.
5)if we cannot give a value to the lookup field then we can't  directly conert lookup relationship to master-detail relationship here first we need to give a value to the lookup field.
6) if we give a value to lookup relationship field we can change that value whenever we required.
Kumaresan S 5Kumaresan S 5
Hi  elghoul,

You can also refer here (http://devfacts.com/master-detail-relationships-vs-lookup-relationships/) .

http://devfacts.com/master-detail-relationships-vs-lookup-relationships/
Suraj Tripathi 47Suraj Tripathi 47
Hi Sally,

Greetings!

Lookup and Master-detail both are types of relationships.
In lookup, both objects are not sharing properties between them means loosely coupled.
In Master-detail, both objects are sharing properties with each other means tightly coupled.

So If you want to create a rollup summary field in the parent object, so create an MD relationship otherwise create a lookup relationship.

If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi