Salesforce is a powerful customer relationship management (CRM) platform that helps businesses manage customer interactions and streamline sales processes. Not just businesses, developers love it because of its ease to use (after you get over the initial learning period).

It has many features that let the developers interact with its elements and use them. One such feature is the ability to establish a relationship between objects. This association between the two affects how they behave and what they will do when changes are made to either of them.

Let’s dive deeper into the relationships in Salesforce. For better understanding we will use two hypothetical objects—Object A & Object B, to explain when needed.

Master-Detail Relationship

The Master-Detail relationship works like a parent-child relationship. Both objects are strongly coupled with each other, sharing many properties. This relationship is extremely useful wherever you need two objects tightly bound as the child record inherits whatever attributes you set to the parent record like visibility and sharing. This transfers almost all control of the child record to the parent record.

Let’s understand with an example:

If Object A is the parent and Object B is the child, deleting Object A will automatically delete Object B. The security settings chosen for Object A determine what applies to Object B. This relationship also allows roll-up summary fields to easily calculate records from the child by using specific functions. Each object can have up to 2 master-detail relationships, it is suggested to keep the number of child records less than 10,000. You can convert a master-detail relationship into a lookup relationship if there are no roll-up summary fields.

Lookup Relationship

Used wherever such strong dependency isn’t required, the Lookup relationship works almost the opposite of the Master-detail relationship. The Salesforce objects in this type of relationship are loosely bound to each other and have their individual settings, i.e., the deletion of one object won’t affect the other. It is not possible to create a roll-up summary field in this type of setup and the look-ups per object are capped at 40. You can convert a lookup relationship into a master-detail relationship if all records i. the lookup field contains a value.

If Object A and Object B are in a lookup relationship, deleting Object A will only delete that object. Both Object A and Object B will have individual sharing, visibility and security settings.

Many-to-Many Relationship

As the name suggests, Many-to-Many relationships are used to link objects to multiple other objects or vice versa. Since there isn’t a specified field for many-to-many relationships, to create one you need to create a junction object. Create two master-detail (parent-child) relationships and use a common object in between. This common object is known as the junction object. This is done to avoid the chaotic system that would arise if you duplicated the lookup field. Do note that the junction object cannot be the parent in another master-detail setup.

Self Relationship

A Self-relationship is when an object creates a relationship with itself. It is a lookup-type relationship and creates a tree of objects. Creating it is also easy.

For instance: When creating a new field, select lookup relationship as the data type and relate the object to the account. Change the Field label to Related Account and you are done.

External Relationship

External Lookup relationships happen when you connect two external objects together (like a child object and an external object). Introduced in Salesforce Connect, this is particularly useful if the data comes from an external database.

Having an excellent knowledge of all the relationships in Salesforce helps in determining which ones to use. The correct use can save you hours. Our certified developers at Atocloud have in-depth knowledge of these and use them effortlessly when they work on any project.

Contact us today to connect with one such developer who has the answers to all your Salesforce problems.