As a Salesforce Admin, Choosing the Data Model Relationship can be very tricky. You may face various scenarios in your day-to-day job where you get confused about which relationship to use and how to connect one object with another.
Data Model is very important when we are working on any project. To Understand the data model we first need to understand about what are the relationships in Salesforce and how one object can be associated with another object.
In this blog post, we will talk about what are the various relationships in Salesforce.
If we include the Polymorphic relationship then there are total 8 types of relationships in Salesforce
The lookup relationship is a very common relationship that you will be seeing in your Projects.
A lookup Relationship is a loosely coupled relationship that means the Parent record is not required on the Child Object.
Lookup relationship is used to relate the objects in a 1:1 or 1:M ( one to many) fashions.
Note: – The Relationship field will always be on the Child Object.
In the above image, there are 2 objects (Contact & Case) that are related to the lookup field.
The contact record is the parent record and the Case is the child record. So the Lookup field will always be on Case Record. ( This is a standard lookup field ).
In the case of a lookup relationship If we delete the parent records then child records will stay in the system and vice versa.
A very important and dangerous relationship in Salesforce is known as Master-Detail Relationship.
Like the lookup relationship, this is also used to create the 1:1 or 1:M (one to many) fashions.
In the case of a master-detail relationship, the master field is always required on the child object.
If we delete the parent record then the associated child record will also get deleted and if we undeleted the parent record using Recycle bin then the child records will also get restored.
When the relationship between 2 objects is a Master-detail relationship, then the child object will not have any owner which means if a user has access to Parent Record then the user will be able to access the child records as well no matter which user has created the child records.
From the above statement, we can conclude that the child record inherits all the security from the parent object.
In the below example, We have 2 objects Invoice & Invoice Line Item.
Let’s take an example here when you go to the market to buy something once you purchased some items say 3 items.
After billing you will get an Invoice and that Invoice will have Invoice Line Items in it.
So the relationship would be master detail. So If you throw(delete) the Invoice into the garbage you will not see the detail of the Invoice Line Items.
In Master-Detail Relationship, we can create the Roll-up Summary field on the Parent object which will be helpful for performing some aggerations such as SUM, Count, MIN & MAX related to Child Object.
For Example, counting the total no of Line Items under Invoice Record.
Before we talk about the many-to-may relationship, let’s talk about an example here.
You have a custom object called Notifications where you create various Notifications. Now you want to associate these notification records with users.
The catch here is that the same notification record can be assigned to multiple users and the same user can be assigned to multiple notification records.
So, how you will achieve this? 🤔
If you create the lookup or master-detail relationship with the user on Notification Object then you will end up having duplicate records.
So, to overcome this issue Salesforce came up with the concept of Junction Object. Junction objects are used to achieve many many relationships.
And we can achieve the Many-To-Many relationship using Junction Object which will have 2 Masters with M-D Relationships.
To Know about Junction Object Click Here.
In the above example, One Notification Record can be attached to multiple Users and one User can be associated with multiple Notification Records.
This is a special type of relationship which is only available on the User object and can only be related to the User Object.
This relationship is used to maintain the hierarchy of the user object.
External lookups are used to connect with external objects ( External Objects are objects out of Salesforce Org).
For Example, you are having friendships with people outside of your organization, college, or city.
In the case of Salesforce, we can consider relationships with external orders, invoices, and payments.
Read More: External Objects in Salesforce
Indirect Lookup relations are used to connect External Objects with Salesforce Standard or Custom Objects.
To Create the Indirect Lookup Relationship with any Standard or Custom Object the parent object must need a field that is marked as Unique and External Id





Self Lookup Relationship is used to connect the same object using Lookup relationship.
For Example, You have created an account(Company) record in Salesforce and that company is a child company.
In the above example, self-lookup will fit best.
Sometimes as a customer we raise a case to Salesforce Support and that case is similar to some other case that we raised so to relate these cases we can also use the lookup field on the Case object which is again a Self Lookup
Polymorphic relationships are used when one child object can be related to multiple parent objects. We can not create the Polymorphic relationship on our own.
However, there are some standard objects which are using this relationship. Those objects are
Mostly we use polymorphic relationships in Salesforce SOQL Query.
For example, you wanted to list all the events related to account and Opportunity. So we will write the query below
List<Event> events = [SELECT Description FROM Event WHERE What.Type IN ('Account', 'Opportunity')];
In the above query What.type will be referenced to the Parent Object API Name.
Irrespective of a role in the Salesforce Industry, it is very important to know the core of Relationships in Salesforce.
I have tried to explain all the relationships that are present in Salesforce.
Thanks for giving in detail information for each relationship
Thanks Sir.. Very good information.
What’s the difference between indirect & external lookup? Nice to have an example for the explanation ☺️
External Lookup is used to relate two external objects.
Indirect Lookup is used to relate Standard or Custom Object with External Object.