Salesforce Master-Detail Relationships Explained

Quick Summary:

A master-detail relationship links a child record's existence to its parent — delete the parent, and every child record deletes with it. It also enables roll-up summary fields, which lookup relationships can't do.

What Is a Master-Detail Relationship?

Master-detail is one of two core relationship types in Salesforce (the other being lookup). In a master-detail relationship, the child record cannot exist without a parent, security on the child inherits from the parent, and deleting the parent cascades to delete every related child record. This is a fundamentally different data model than a lookup, where the two records are related but independent.

Think of an Invoice and its Line Items: a line item genuinely has no meaning without the invoice it belongs to. If the invoice is deleted, the line items should go with it — they were never meant to exist independently. That's the exact scenario master-detail is built for.

⚠️ Before You Start

Converting an existing lookup relationship to master-detail requires every existing detail record to already have a value in the relationship field — you can't convert with orphaned records present. On an object with real production data, this often means a data cleanup project before the conversion is even possible.

Master-Detail vs Lookup: The Real Difference

Key Distinctions

Master-Detail:
  - Child cannot exist without parent
  - Deleting parent deletes children (cascade)
  - Supports roll-up summary fields
  - Child inherits parent's sharing/security

Lookup:
  - Child can exist independently
  - Deleting parent does not delete children
  - No roll-up summary support
  - Child has its own sharing settings

How to Create One

  1. Go to the child object's Fields & Relationships and click New.

  2. Select Master-Detail Relationship as the field type.

  3. Choose the parent object and configure sharing settings (read-only vs read/write for detail records).

  4. Set field-level security and add the field to the appropriate page layouts.

  5. Once created, add a roll-up summary field on the parent to sum, count, or find min/max values across its children.

A Real-World Example

Consider an Opportunity with multiple Products (a standard master-detail relationship already built into Salesforce). Because it's master-detail, the Opportunity can display a roll-up summary field showing the total value of all its line items automatically — no formula field or trigger required. Delete the Opportunity, and the line items disappear too, since they never had independent meaning outside that specific deal.

🚫 Common Mistake

Choosing master-detail by default without considering whether the cascade-delete behavior is actually desired. Losing an entire set of child records because a parent was deleted accidentally is one of the most common, and most painful, Salesforce data mistakes — and unlike most Salesforce actions, there's no simple undo.

💡 Pro Tip

You can have up to 2 master-detail relationships on a single object, enabling many-to-many junction objects — a common pattern for connecting two unrelated objects through a middle object that references both.

Frequently Asked Questions

Can I convert master-detail back to lookup?

Yes, this direction is generally easier than lookup-to-master-detail, though roll-up summary fields depending on the relationship will break and need to be removed first.

What happens to reports built on the child object if I change the relationship type?

Reports referencing the relationship may need to be rebuilt, since the underlying join logic (and available fields) changes between relationship types.

Does master-detail affect record ownership?

Yes — detail records don't have their own Owner field by default; ownership and sharing follow the parent record instead.

Can child records be reparented to a different master record?

Not by default. Admins can enable the "Allow reparenting" option on the relationship definition for custom objects, which lets detail records be moved to a different parent after creation.

Can a standard object be on the detail side of a relationship with a custom object as master?

No — a standard object cannot be on the detail side of a master-detail relationship where the master is a custom object. The relationship direction matters here.

Can Lead or User be the master in a master-detail relationship?

No, Lead and User cannot be on the master side of a master-detail relationship — this is a platform restriction, not a configurable setting.

Can a custom object on the detail side have its own sharing rules?

No — because ownership and sharing are inherited from the master, detail-side custom objects can't have independent sharing rules, manual sharing, or queues.

What happens to a detail record if I delete the master and then undelete it?

Undeleting the master record from the Recycle Bin also undeletes its related detail and subdetail records automatically, restoring the full hierarchy.

How many master-detail relationships can one object have?

An object can be on the detail side of up to 2 master-detail relationships, enabling three-way junction patterns for complex many-to-many data models.

Is the master-detail field required on the page layout?

Yes — the master-detail relationship field is always required, since a detail record genuinely cannot be saved without a parent already assigned.