Salesforce Lookup Relationship and Salesforce Master-Detail Relationship: An Overview

The relationship is used to connect different Objects within org. Salesforce provides the following types of relationships :

  • Lookup relationship
  • Master-Detail relationship
  • Self-relationship
  • External lookup relationship
  • Indirect lookup relationship
  • Hierarchical relationship

dont miss out iconDon’t forget to check out: Look ups and Master Detail

Lookup Relationship :

Lookup relationship is a type of Salesforce relationship that is used for where you need to have a relationship between two objects without affecting their properties and also their security. It can be a one-to-one or one-to-many relationship. For example, an account to opportunity relationship is one-to-many because a single account can have many related opportunities.

Lookup relationship is a loosely coupled relationship between Salesforce objects, which means if a parent record gets deleted, then the child record will not be affected because both records have their own sharing settings. And also if we want to create a child record, then we don’t need a parent record.

In Lookup Relationship, We can not create a Roll-up summary field. And also, Cascade record deletion is not present in the lookup relationship.

Important Points of Lookup Relationship:

  • Each object is allowed to have a maximum of 25 lookups.
  • A lookup field is not required on the page layouts of the detail object.

Master-Detail Relationship : 

In the Salesforce Master-Detail relationship, Master refers to the parent relationship and the Detail refers to the child relationship.

Master-Detail relationship is a type of salesforce relationship that defines the relationship between parent and child. If we want to create a child record, then the parent record will always be needed. In simple words, we can not have a child record without a parent/master record. In other words, the child record doesn’t work as a stand-alone because it’s highly dependent on the parent.

Master-Detail Relationship is a strongly coupled relationship between Salesforce objects, which means that if a parent record gets deleted, then its child record will also be deleted because the visibility of child records is controlled by the parent record. We can not set profile object permissions for a child record because child record doesn’t have their own sharing settings.

In Master-Detail Relationship, We can create a Roll-up summary field and the roll-up summary field allows us to calculate values from child records, such as the number of child records present in a parent record.  And also, Cascade record deletion is present in the Master-Detail relationship.

Master-Detail relationship is used when you want to control the behavior of the child record based on the value in the parent record like who can view the child’s record. For example, Online shopping site wants to keep any discounts on their product. With a master-detail relationship between product and discount, you can delete the product then all its associated discounts should also be eliminated.

In the Master-Detail Relationship, the parent object does not allow orphaned child records so we can say that, every record in the child object must have their parent Object. And also, a child of a master-detail relationship can not become a parent of another object. In other words, Child record can not have their own child.

If you want to create a master-detail relationship on existing records then you have to first create a lookup relationship for that record and after that convert that lookup relationship into the master-detail relationship. Also, we can create many-to-many relationships using two master-detail relationships in an object and it is called a Junction object.

Important Points of Master-Detail Relationship :

  • Each object is allowed to have a maximum of 2 master-details.
  • The standard object can not be a child of a custom object.
  • The Master-Detail field is always required on the page layouts of the detail object.
  • For the best practice, You don’t create more than 10,000 child records in the master-detail relationship.

Popular Salesforce Blogs