Beat the Heat with Cool Discounts

Grab Up to 20% Off on Self-Paced Courses!

Explore Now
4

Relationship in Salesforce

Salesforce is a powerful cloud-based platform for managing data, streamlining the sales process, sales & marketing alignment, tracking analytics, customer behaviour and performance. So, it’s a very huge platform catering to multiple business challenges. When we talk about the relationship in Salesforce, we mean the different data objects.

These objects (company, name, etc) are crucial for maintaining a unified and comprehensive view of your organization’s information. In this blog, we’ll explore the concept of relationships in Salesforce, focusing on the various types of relationships, including lookup, master-detail, and external lookup relationships.

What is Relationship in Salesforce

Relationships in Salesforce refer to the connections between different data objects within the platform. These relationships enable you to associate and link records, facilitating a structured and organized approach to data management.

Salesforce offers various types of relationships, including master-detail and lookup relationships, which play a crucial role in building and maintaining data relationships for comprehensive data analysis and reporting. Here is a simple example for you to understand relationships in Salesforce: 

Imagine your Salesforce org as a puzzle, with each piece representing a different aspect of your business, such as customers, products, and orders. To see the complete picture, you need a way to connect these puzzle pieces. Relationships in Salesforce serve as the glue that holds your data together and enables you to access related information effortlessly.

Types of Relationships in Salesforce

Salesforce offers several types of relationships to establish connections between objects:

1. Lookup Relationship

    A lookup relationship is a one-to-many relationship that joins a single object with another object without imposing rigid dependency between them.

    lookup relationship

    Example: In this scenario, if an Opportunity related to a certain task gets deleted – task will remain the same, i.e. still present in the CRM.

    2. Master Detail Relationship

    The master-detail relationship is a tightly connected relationship, where deleting the parent record also deletes its associated child records. While this behavior can be highly useful, it often causes unnecessary concern.

    Additionally, in a master-detail setup, the parent record governs certain attributes of the child records—such as sharing rules and visibility. The child record inherits the security settings specified for the parent by default.

    Master Detail Relationship

    Example: In this scenario, deleting the parent Insurance Policy will automatically delete all related child Insurance Policy Transaction records.

    For a better understanding of the key differences between Lookup and Master-Detail relationships in Salesforce, we will discuss them briefly in the table below:

    Difference between Lookup Relationship and Master-Detail Relationship

    Criteria Lookup Relationship Master-Detail Relationship
    Coupling It is loosely coupled. It is strongly coupled.
    Roll-up Summary The Roll-up summary field is not available. The Roll-up summary field is available.
    Parent Record Requirement A parent record is not required when creating a child record. A parent record is required to save a child record.
    Page Layout Requirement Lookup fields are not required on the page layout of the detail record. In case you make them a required field it is advisable. Master-Detail field is always needed on the page layout of the detail record.
    Standard Object on Child Side Standard object record can be on the detail side of a custom object in a lookup relationship. Standard object record cannot be a child.
    Ownership The record ownership of child records is not controlled by the parent by default. The parent controls the record ownership of the child records. The owner field is not available on the detail record in master-detail relationship queues. Also, the sharing rules and manual sharing is not possible for the detail records as it requires the owner field.
    Child Without Parent It is possible to have a child record without a parent. It is not possible to have a child record without a parent.
    Maximum Relationships It can have a maximum of 40 lookups on an object. It can have a maximum of two master-detail on an object.
    Cascade Delete No cascade delete. Cascade delete can be done.

    3. Many-to-Many Relationship:

    In Salesforce, a many-to-many relationship is applied when records of one object need to be linked to several records of another object, and vice versa. For instance, a Student may enroll in more than one Course, and a Course may have numerous Students.

    Salesforce doesn’t support a direct many-to-many relationship out of the box, so we create it using a Junction Object. A junction object is a custom object that has two master-detail relationships—one to each of the objects you want to relate. In the example above, an Enrollment object can serve as a junction between Student and Course.

    This approach allows you to store additional data about the relationship itself (like enrollment date or status) and keeps the data model clean and scalable.

    Many to Many Relationship

    Example: In this scenario, Account and Contact have many-to-many relationships and their junction object is Account Contact Relationship.

    4. Self-Relationship

    A self-relationship is when a record within an object is related to another record from the same object. This is done by creating a lookup field on the object that points back to itself.

    This type of relationship is useful for modeling hierarchical or dependent structures within the same object. It helps in organizing data more effectively by showing how one record is related to another of the same type.

    Self Relationship

    Example: In an Insurance Policy object, you might have a “Comprehensive Plan” as a parent policy, and link several child policies—like auto, home, and life insurance—to it using a self-relationship. This creates a Policy Hierarchy, allowing insurers to easily manage and view all related policies under one bundled plan.

    5. External Relationships  

    Salesforce supports two special lookup types for connecting to external data:

    • Indirect Lookup Relationship: Links a Salesforce object to an external object using a matching external ID. For example, a Customer record in Salesforce can be linked to Order data stored in an external order management system by matching the customer’s external ID.
    • External Lookup Relationship: Connects two external objects. For instance, Order and Shipment records stored in an external system can be related to each other and surfaced in Salesforce, even though neither record exists in Salesforce natively.

    6. Hierarchical relationships

    The hierarchical relationship is a special type of lookup available only on the User object in Salesforce. It allows one user to reference another, typically to define reporting lines—such as assigning a manager to a user.

    Setting Up Relationships in Salesforce

    Creating relationships between objects in Salesforce is relatively straightforward:

    • Log in to your Salesforce org and go to the Setup menu.
    Log in to your Salesforce org and go to the Setup menu
    • In the Quick Find box, type “Objects” and select “Objects and Fields.” -> Object Manager
    In the Quick Find box type Objects and select Objects and Fields Object Manager
    • Select the object for which you want to create a relationship.
    Select the object for which you want to create a relationship
    • Scroll down to the “Custom Fields & Relationships” section and click “New” to create a new custom field.
    Scroll down to the Custom Fields & Relationships section and click New to create a new custom field
    • Choose either “Lookup Relationship” or “Master-Detail Relationship,” depending on your requirements.
    Choose either Lookup Relationship or Master Detail Relationship depending on your requirements
    • Follow the prompts to specify the related object and other settings. For lookup relationships, you’ll need to define a related list for the parent object to display related child records.
    Follow the prompts to specify the related object and other settings 1
    Follow the prompts to specify the related object and other settings 2
    • After configuring the relationship details, save your changes.
    After configuring the relationship details, save your changes

    Benefits of Relationships in Salesforce

    Establishing relationships between objects in Salesforce offers several advantages:

    • Relationships ensure that related data is accurate and consistent throughout your Salesforce org.
    • Users can easily access and view related information without navigating between multiple records.
    • You can automate processes, such as record updates or calculations, based on related data changes.
    • Relationships help you define who can access or modify related records, enhancing data security.
    • Relationships enable you to create meaningful reports and dashboards that provide insights into your organization’s performance.
    Salesforce-Admin-Training-Banner

    In Salesforce, relationships are the key to unlocking the full potential of your data. Whether you’re connecting customer data to sales opportunities or linking products to orders, understanding and utilising the various types of relationships available in Salesforce can significantly improve your data management and decision-making capabilities. In the next part of this series, we will discuss more about Master-Detail relationships in Salesforce.

    Next Topic

    Need more support?

    Get a head start with our FREE study notes!

    Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.

    Book Free15-Minutes Career Counselling