
Object Relationships – Salesforce Admin Tutorial

Object Relationships are very important when you want to expand your data model and take it to the next level by defining a connection among objects. For example, if you have say custom objects named as “School” and “Student” then it is important to define a relation between these 2 objects to see to which school a specific student belongs to or number of students in a specific school.
Therefore to implement such use cases, Salesforce provides special types of fields to define different types of relations.
Types of relationships

- Lookup Relationships
As defined by salesforce, it links two objects together so that you can “look up” one object from the related items on another object and It can be one-to-one or one-to-many. In the example discussed above School and Students have one-to-many as a school can have many students.
This sort of relationship can be utilized when we fair ought to have the relationship between two objects but not a coordinate reliance on each other.
- Master-Detail Relationships
As the name describes, in this relationship one of the objects is master and another is detail. Therefore, the master object controls the behavior of the detail objects. A few of the highlights are as takes after:- Detail object inherits all the permissions from its master.
- Deleting the master record will delete all of its related child records.
- Roll-up summary fields can only be created on master-detail related records.
Comparison of Lookup and Master-Detail Relationships
Lookup Relationship | Master-detail Relationship |
Limit – We can create a maximum of 40 lookups on an object. | Limit – We can only create maximum of 2 master details on an object. Salesforce support can be contacted to increase the limit |
A child record can exist without a parent. | A child cannot exist without a parent |
By default record possession of child records isn’t controlled by the parent. | Record ownership of child records is controlled by the parent |
Cancellation of the parent fair erases the related field within the child but not the full record | On the off chance that a ace record is erased at that point the record of its detail too gets erased beside it. |
While creating a child record, a parent record is not mandatory. | While creating a child record, a parent record is required. |
Roll-up summary field not available. | Roll-up summary field is available |
- Derived Relationships
- Many-to-many relationships
In order to handle a situation where we need to allow each record of one object to be linked to multiple records from another object and vice versa, we develop a many-to-many relationship. It is built by means of multiple master-detail relationships and using a junction object(intermediate object) between the two objects.
For example: We have two custom objects say “Candidate” and “Position”.So in order to allow a candidate to apply for multiple jobs and to have multiple candidates for one job, we will develop a many-to-many relationship. It is achieved by creating a junction object, say: “Job Application” with two master-details relationships i.e. one for candidates and one for Job openings. Please refer below the schema diagram:
- Many-to-many relationships

- Hierarchical relationships
This is a very simple type of relationship having its uniqueness. It can only be used on the “User” object to create a hierarchy of users. Sample implementation may include the creation of a lookup field on the user object to define the selected user’s manager. - Self Relationships
When we need to create a lookup relationship on an object and that too related to the same object, then that relationship is defined as a self relationship. For example, if we have to define a company (account) with its subsidiary companies(accounts), then creation of a lookup field on Account with a related object as Account only will serve the purpose.
Steps to create a Lookup relationship:
- From Setup, go to Object Manager.
- Select the object [which will be used to select the related parent record] .
- On the sidebar, click Fields & Relationships.
- Click New.
- Choose Lookup Relationship and click Next.
- For Related To, choose [Object with which it will be related – Parent Object].
- Click Next.
- For Field Name, enter [Name to depict the relation], then click Next.
- Click Next, Next, and Save.
Similarly, we can create other relationships as per our needs.
Comments are closed.