Master-Detail Relationships in Salesforce: A Complete Guide

When working with Salesforce, one of the most important concepts to understand is how objects relate to each other. Salesforce provides different types of relationships, and among them, the Master-Detail Relationship is one of the most powerful.

In this blog, we’ll break down everything you need to know about Master-Detail Relationships, explain how they work, where they should be used, and show diagrams for easy understanding.


A Master-Detail Relationship in Salesforce is a tight bond between two objects, where one object (the Detail) depends completely on the other object (the Master).

  • The Master object controls the behavior of the Detail object.
  • The Detail record cannot exist without its Master record.
  • If the Master record is deleted, all related Detail records are also deleted (cascade delete).

👉 Think of it as a Parent-Child relationship.

  • Parent = Master
  • Child = Detail

  1. Ownership & Sharing
    • The Detail record does not have its own Owner field.
    • It inherits the sharing and security settings from the Master record.
  2. Cascade Delete
    • If a Master record is deleted, all its associated Detail records are automatically deleted.
  3. Roll-Up Summary Fields
    • Roll-up summary fields can be created on the Master object to perform calculations (SUM, COUNT, MIN, MAX) on fields from the Detail object.
  4. Mandatory Relationship
    • While creating a Detail record, you must always link it to a Master record. It cannot exist independently.
  5. Security & Access Control
    • The Detail record’s access is always controlled by the Master record’s access.

Here’s a simple diagram to visualize the relationship:

Example in Salesforce:

  • Master: Account
  • Detail: Contact (if we set it as Master-Detail)

If the Account is deleted, all its Contacts will also be deleted.


It’s easy to confuse Master-Detail with Lookup Relationship, so let’s compare:

FeatureMaster-DetailLookup
DependencyChild must have a ParentChild may exist without Parent
OwnershipInherited from MasterIndependent
Deletion BehaviorCascade deleteNo automatic delete
Roll-Up SummarySupportedNot Supported
Security & SharingControlled by MasterIndependent

  1. Invoices and Invoice Line Items
    • Invoice (Master)
    • Line Items (Detail)
  2. If the invoice is deleted, all related line items should be deleted too.
  3. Order and Order Products
    • Order (Master)
    • Products (Detail)
  4. Products can’t exist without an Order.
  5. Survey and Survey Responses
    • Survey (Master)
    • Responses (Detail)
  6. Each response belongs to a survey and cannot exist on its own.

  1. Go to Setup → Object Manager.
  2. Select the Detail object (the child).
  3. Go to Fields & Relationships → New.
  4. Choose Master-Detail Relationship.
  5. Select the Master object (the parent).
  6. Set up field-level security, layout, and save.

  • A custom object can have up to 2 Master-Detail Relationships.
  • Converting a Lookup to Master-Detail is possible (if all records have a parent).
  • You cannot set a Master-Detail Relationship if the object already has existing records without a parent.

The Master-Detail Relationship is a powerful way to enforce data dependency in Salesforce. It ensures that child records are always tied to a parent record, making data cleaner and more reliable. Features like cascade delete and roll-up summary fields make it one of the most widely used relationships in Salesforce.

👉 Remember:
Use Master-Detail when the child should not exist independently, and use Lookup when the child can stand alone.


Leave a Reply

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