Types of relationship in Salesforce

  • Master-detail relationship

  • Lookup relationship

  • Self-relationship

  • External lookup relationship

  • Indirect lookup relationship

  • Many-to-many relationship (junction object)

  • Hierarchical relationship

Master-detail relationship

It is a closely coupled Salesforce object relationship, which ensures that if a

master record is deleted, the child records associated with it are also deleted.

In this type of relationship, the parent record controls the behaviour of the child record regarding visibility and sharing. It means the security setting of a parent object applies to the child object.


Example : -If we create a master-detail relationship between Meetup and Participant objects, where Meetup acts as the parent object and the

Participant acts as the child object, all the related Participant records will also be removed if anyone deletes a Meetup record.


When there is a master-detail relationship between two objects, you can create a unique type of field over the master object, called Roll-up summary. A roll-up summary field allows us to calculate values from child records, such as the number of child records linked to a parent record.




Highlights to remember:

  1. If the parent record is deleted the respective child records are also deleted.

  2. The parent record controls the behaviour of the child record regarding visibility and sharing. It means the security setting of a parent object applies to the child object.

  3. Roll-up summary field allows us to calculate values from child records, such as the number of child records linked to a parent record.


Lookup relationship

It is a loosely coupled relationship between Salesforce objects, which ensures that even

though the parent record is removed, the child records remain in the system.

Here, both the parent and child have their own sharing settings and security controls.




Difference between master-detail and lookup relationships

Take a look at the differences between the lookup

and the master-detail relationship in the following table:




Self-relationship


Self-relationship is another example of a lookup relationship. In Salesforce, we can use lookup relationships to create self-relationship among objects; we can have a maximum of 40 self-lookups. For example as shown in the following screenshot:



External lookup relationship


External lookup relationship allows us to link an external object to a parent external object whose data is stored in an external data source. In other words, it allows us to link two external objects.


Indirect lookup relationship


An indirect lookup relationship allows us to link an external object to a standard or custom object. We can only create an indirect lookup to an object with a unique external ID field on the parent object that is used to match the records in this relationship. While creating an indirect lookup relationship field on an external object, we have to specify the child object field and the parent object field to match and associate records in the relationship.


Many-to-many relationship

The many-to-many relationship is made with the help of a junction object.

If you have two objects, called Case and Article, and you want to relate these two objects in such a manner that one case can have multiple articles and one article is linked to many cases, then we have to use the many-to-many relationship.

In this case, we can create the third object, let's say, Solution with two master-detail relationships with Solution - Case and Solution - Article.

9 views0 comments

Recent Posts

See All

Salesforce Configuration Topics

CRM - Customer Relationship Management 1.             What is CRM(Customer Relationship Management)? 2.             CRM Basic entities 3.             Sub Modules of CRM 4.             Existing CRMs Sa

Governor Limits in Salesforce

Static Apex Limits Per transaction apex limits These limits are useful for counting every apex transaction. While we discuss batch apex, limits which are present for executing records batch are reacti

Daily Information | Daliylinx are related to General information, Technology, Salesforce, Newspapers, Telugu Newspapers, Pets, Cars etc

  • Facebook