Object Relationship in Salesforce

Data Relationship between two or more Objects in Salesforce is the most crucial part. After knowing about different Objects (Standard and custom), we are going to discuss Object Relationship in Salesforce. When we create any relationship between objects, the complexity of the data-model will also be increased. The object is considered as a database table in Salesforce. After completing this article, you will know various types of Object Relationships and their typical cases, steps to create or modify the lookup relationship, steps to create a Master-Detail Relationship, and which Object Relationship will be best suited to extend your Salesforce data model. So, let’s start with the definition of Object Relationship.

What is an Object Relationship in Salesforce?

Salesforce provides a feature of connecting two or more objects with one another. Hence, an Objects Relationship is defined as a field type to connect two objects together.

Object Relationship helps us to create a single one-to-many relationship instead of multiple duplicate fields so we don’t need to track the record of each field individually.

Example:

Let’s understand with a standard object named Account object. So if someone opens an account, they will find various people account information who is a member of that organization. Further, there will also be another standard object named Contact, which stores the contact information of that person in the database.

Now, instead of creating a third object which stores the information of those people with their account and contact together, you can also create a relationship between these objects. It will reduce unnecessary object creation.

After creating a relationship between them, you will able to find the second object’s information on the “Related tab” of the first object. You can also create a new contact to an account object directly by clicking on the New Contact button.

Account to Contact Relationship is the best example of a standard relationship in Salesforce. Similarly, you can also create a custom relationship between two objects in Salesforce.

Let’s understand the various types of relationships you can create in Salesforce.

Types of Object Relationship in Salesforce

There are two important types of Object Relationship in Salesforce;

  • Lookup Relationship
  • Master-Detail Relationship (MDR)
  • Hierarchical Relationship
  • Many-to-Many Relationship

Lookup Relationship

Relationship means dependency of values. In a Lookup Relationship, two objects must be connected together in such a way so that we can ‘’look up’’ on an object from the related tab on another object.

A Lookup Relationship can be either one-to-one or one-to-many. In a one-to-one lookup relationship, a single object can have only one object while in a one-to-many lookup relationship, a single object can have multiple objects together.

Example: The Account to Contact relationship is a one-to-many Lookup Relationship because a single account can have many contacts simultaneously.

Master-Detail Relationship (MDR)

It is a Parent-child relationship where a master object is considered as a parent while a Detail object is considered as a Child object.

  • Master- Parent
  • Detail- Child

A Master-Detail Relationship is quite similar to a Lookup Relationship in which a Master or parent object controls the certain behavior of a Detail or child object.

In a Master-Detail Relationship, if the master (parent) record is deleted; the detail (child) record also will be deleted automatically. In this relationship, a detail object can’t exist individually; it should be associated with a parent object. While creating a Master-Detail Relationship, a related field must be created on the detail object.

Note: Standard objects are not allowed as child objects, only custom objects are allowed as child objects.

Example: A relationship between Product and offer is an example of a Master-Detail relationship. When we delete the Product object then offers associated with the product will automatically be deleted.

In Amazon and Flipkart apps, a product shows different offers related to it but when this product is removed from the app then all offers attached with this product get automatically removed from the application.

Hierarchical Relationship

A hierarchical relationship is a special type of one-to-one lookup relationship which is only available only for the user object. It is used to create management chains between users in any organization for e.g. Manager and Executives of a process.

Many-to-Many Relationship

In a Many-to-Many Relationship, two Master objects are connected to a common child object, where the child objects are considered as Junction objects, and the relationship between two master objects is called a Many-to-Many relationship.

 

About the Author: Admin

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *

Join Our Community Of Bloggers