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
pranavshahpranavshah 

what is difference between parent child and master-detail in salesforce

Hi,

can please someone explain me parent child & master detail relationship in salesforce

Regards
Pranav Shah
9029966976
Best Answer chosen by pranavshah
Prerna Agrawal13Prerna Agrawal13
Hi Pranav,

In case of master detail is that the parent is required field and when you will delete the parent the child will be deleted. But in parent child (lookups), we can delete the parent and the child will not be deleted, only the field value will be empty.

Also, in master-detail we can create roll-up summary fields.

Hoep this helps!

All Answers

Prerna Agrawal13Prerna Agrawal13
Hi Pranav,

In case of master detail is that the parent is required field and when you will delete the parent the child will be deleted. But in parent child (lookups), we can delete the parent and the child will not be deleted, only the field value will be empty.

Also, in master-detail we can create roll-up summary fields.

Hoep this helps!
This was selected as the best answer
sfdcMonkey.comsfdcMonkey.com

Hi Pranav,

Difference between master-detail relationships and lookup relationships

 
 
Master-detail relationship
 
Lookup relationship
 
You can define master-detail relationships between custom objects or between a custom object and a standard object (standard object must be the parent).
 
You can define a relationship between any two objects, standard or custom.
 
When a record in a master object (parent) is deleted, all the records in the detail object (child) that are related to that master record will be deleted.
 
When a parent object is being deleted, you can configure a child object to either clear the parent record value in the child record or prevent deletion of the parent record.
 
All child records must have a related parent record.
 
The parent record may not require a related parent record.
 
The ownership of the child record is determined by the related parent record. Child records do not have an owner.
 
Each child record has an owner and is not related to the parent record.
 
The detail record inherits sharing and security from the master record.
 
There is no security or inheritance between related parent and child records.
 
To relate an object to another object, no records should exist in the child object.
 
To relate an object to other objects, there is no condition on the number of records.
 
If you have the Roll-Up Summary field in the parent object, any create, edit, or delete action in the child record will trigger an edit action in the parent object. If you have a validation rule and other rules in parent object, the validation rules will trigger for the parent object.
 
You cannot create the Roll-Up Summary field in the lookup relationship using out-of-the-box Salesforce functionality.
 
Supports cross-object workflow. You can configure a field update action to update a field in the parent record using a value from the child record.
 
Does not support cross-object workflow.
 
 
 
To create a master-detail relationship for an existing object with records as the child object, you can initially define it as a lookup relationship, populate all parent fields for all records, and then change the relationship to a master-detail relationship.
 
 
 
You can build a many-to-many object relationship using two master-detail relationships in a single custom object, which is known as a junction object in that case. 

more :
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

Hope it will helps you, kindly close you query by choosing best answer if you got your answer 
thanks
deepak_sfdcmec5deepak_sfdcmec5
Dear pranav,

                Hope the below relationship base details will be useful for further queries about relationship:

Master-detail relationship: If parent deleted child also deleted

Lookup relationship: If parent deleted child will not be deleted

Self-relationship: When an object has a lookup with itself, it is a self-relationship

External lookup relationship: This type links an object to an external object

Indirect lookup relationship: It links an external object to a standard or custom object in the same way that a regular lookup relationship              links standard or custom objects

Many-to-many relationship (junction object): A junction object is a custom object with two master-detail relationships, and is the key to making a many-to-many relationship

Hierarchical relationship:Jul 2, 2012 - It seems that it's exactly like a Lookup relationship, except the only things that are "special" about this type of relationship are: It's only available on the User object
pranavshahpranavshah
In one interview i had a question like How many relationship can be defiend on junction object??
 
My ans was one : i.e Many To Many Relationship

is it correct//
Mukesh Kumar 107Mukesh Kumar 107
Junction object or other custom object can have max 2 Master-Detail and many many (as Governor Limit ) Lookup Relationship.