Master-Detail vs Lookup Relationships
In Salesforce, Master-Detail and Lookup are two primary types of object relationships, each serving distinct purposes. **Master-Detail Relationship:** This is a tightly coupled parent-child relationship where the master (parent) record controls the behavior of the detail (child) record. Key charac… In Salesforce, Master-Detail and Lookup are two primary types of object relationships, each serving distinct purposes. **Master-Detail Relationship:** This is a tightly coupled parent-child relationship where the master (parent) record controls the behavior of the detail (child) record. Key characteristics include: 1. **Ownership & Security:** The detail record inherits its Owner, sharing settings, and security from the master record. You cannot set independent sharing rules on the detail object. 2. **Cascade Delete:** When a master record is deleted, all related detail records are automatically deleted (cascade delete). 3. **Required Field:** The relationship field on the detail record is always required — a detail record cannot exist without a parent. 4. **Roll-Up Summary Fields:** Master-Detail relationships allow you to create roll-up summary fields on the master object to aggregate data (SUM, COUNT, MIN, MAX) from detail records. 5. **Reparenting:** By default, you cannot change the master record once set, unless you enable the 'Allow Reparenting' option. 6. **Limits:** An object can have up to two master-detail relationships. **Lookup Relationship:** This is a loosely coupled relationship that simply links two objects together without strict dependency. Key characteristics include: 1. **Independence:** The child record exists independently. Deleting the parent does not automatically delete the child (unless cascade delete is configured). 2. **Optional Field:** The lookup field is not required by default — records can exist without a parent reference. 3. **No Roll-Up Summary:** Standard roll-up summary fields are not natively supported (though you can use tools like Declarative Lookup Rollup Summaries or Flow). 4. **Independent Security:** Each object maintains its own sharing and security settings. 5. **Reparenting:** You can freely change the parent record at any time. 6. **Limits:** An object can have up to 40 lookup relationships. **When to Use:** Use Master-Detail when the child record has no meaning without the parent and you need roll-up summaries. Use Lookup when objects are related but independent, and the relationship is optional. Understanding these differences is critical for proper data modeling on the Salesforce platform.
Master-Detail vs Lookup Relationships in Salesforce: A Complete Guide for Platform Developer 1 Exam
Why Master-Detail vs Lookup Relationships Matter
Understanding the difference between Master-Detail and Lookup relationships is one of the most foundational and frequently tested topics on the Salesforce Platform Developer 1 exam. Relationships define how objects connect to each other, and choosing the correct relationship type directly impacts data integrity, security, record behavior, and application logic. Nearly every Salesforce application relies on object relationships, so mastering this topic is critical for both the exam and real-world development.
What Are Object Relationships in Salesforce?
Salesforce uses relationships to link records on different objects together, similar to foreign keys in relational databases. The two primary relationship types for custom objects are Master-Detail and Lookup. Each has distinct characteristics that affect how data behaves across the platform.
Master-Detail Relationships
A Master-Detail relationship creates a tight, parent-child bond between two objects. The master (parent) object controls certain behaviors of the detail (child) object.
Key Characteristics:
• Tightly coupled: The detail record cannot exist without a master record. The master-detail relationship field on the child is required — it cannot be blank.
• Cascade delete: When a master record is deleted, all related detail records are automatically deleted as well. When a detail record is undeleted, its master record must also be undeleted (or still exist).
• Ownership and sharing: The detail record inherits its Owner, sharing settings, and security profile from the master record. The Owner field is not available on the detail record. You cannot set sharing rules, OWD, or manual sharing directly on the detail object in a master-detail relationship.
• Roll-Up Summary Fields: Only master-detail relationships allow you to create roll-up summary fields on the master object. These fields can calculate COUNT, SUM, MIN, or MAX across related detail records.
• Reparenting: By default, once a detail record is associated with a master, it cannot be reparented to a different master record. However, there is an option called Allow Reparenting that can be enabled on the relationship to permit changing the master record.
• Limit: A custom object can have up to 2 master-detail relationships. If it has two, it becomes a junction object, enabling a many-to-many relationship between the two master objects.
• Standard objects as detail: Standard objects cannot be the detail (child) side of a master-detail relationship. The detail must be a custom object (though the master can be either standard or custom).
• Record-level access: Since the detail inherits security from the master, if a user can see the master record, they can see the related detail records (subject to field-level security).
Lookup Relationships
A Lookup relationship creates a loose association between two objects. It links records together but does not create a strong dependency.
Key Characteristics:
• Loosely coupled: The lookup field is not required by default (though it can be made required). A child record can exist without a parent record — the lookup field can be blank/null.
• No cascade delete (by default): When the parent record is deleted, the child record is not deleted. Instead, the lookup field on the child is simply cleared (set to null). However, administrators can configure the lookup relationship to either Clear the value, Don't allow deletion of the lookup record, or (in some contexts) cascade delete behavior.
• Independent ownership and sharing: The child record has its own Owner field and its own sharing and security settings. Sharing rules, OWD settings, and manual sharing can be independently configured on the child object.
• No Roll-Up Summary Fields: You cannot create roll-up summary fields on the parent object in a lookup relationship using standard declarative tools. (You would need to use Apex triggers, flows, or AppExchange packages like Declarative Lookup Rollup Summaries to achieve similar functionality.)
• Reparenting: By nature, lookup relationships allow reparenting — you can change the parent record at any time, or set it to null.
• Limit: A custom object can have up to 40 lookup relationships.
• Flexibility: Both standard and custom objects can be on either side of a lookup relationship. You can create lookups between two standard objects, two custom objects, or a mix.
Side-by-Side Comparison
Feature — Master-Detail — Lookup
• Relationship field required? — Yes, always — No (optional by default)
• Child can exist independently? — No — Yes
• Cascade delete? — Yes — No (field cleared by default)
• Roll-Up Summary Fields? — Yes — No (not natively)
• Owner field on child? — No (inherited from master) — Yes (independent)
• Sharing/Security? — Inherited from master — Independent
• Reparenting allowed? — Only if enabled — Yes, always
• Max per object? — 2 — 40
• Standard object as child? — No — Yes
How It Works in Practice
Scenario 1: Invoice and Line Items
An Invoice__c object has multiple Line_Item__c records. A line item has no meaning without its invoice. If the invoice is deleted, all line items should be deleted too. The business needs to see totals (SUM of line item amounts) on the invoice. This calls for a Master-Detail relationship, with Invoice as the master and Line Item as the detail. A roll-up summary field on Invoice can sum the Amount field from Line Items.
Scenario 2: Contact and Campaign
A Contact might optionally be associated with a Campaign, but the Contact should continue to exist even if the Campaign is deleted. The Contact has its own owner and sharing rules. This calls for a Lookup relationship.
Scenario 3: Junction Object for Many-to-Many
A Student can enroll in many Courses, and a Course can have many Students. You create an Enrollment__c junction object with two Master-Detail relationships — one to Student and one to Course. This enables the many-to-many relationship.
Converting Between Relationship Types
• You can convert a master-detail to a lookup — this is generally straightforward.
• You can convert a lookup to a master-detail, but only if all existing child records have a value in the lookup field (it cannot be null for any record), because master-detail fields are required.
• You cannot convert relationships if there are existing roll-up summary fields that depend on the master-detail relationship — you must delete the roll-up summary fields first.
Important Nuances for the Exam
• Junction objects use two master-detail relationships and are the standard pattern for many-to-many relationships.
• In a junction object, the first master-detail relationship created determines the primary master, which controls the record's look and feel (page layouts, record types) and the related list behavior on both masters.
• External Lookup and Indirect Lookup relationships are additional types used for Salesforce Connect and external objects — be aware they exist but they are less commonly tested compared to Master-Detail and Lookup.
• Hierarchical relationships are a special type of self-lookup available only on the User object.
• When considering governor limits and SOQL, the relationship type affects how you write queries. Master-detail relationships support inner and outer joins naturally via relationship queries.
Exam Tips: Answering Questions on Master-Detail vs Lookup Relationships
1. Read carefully for keywords: If the question mentions "roll-up summary," "cascade delete," or "the child cannot exist without the parent," the answer almost certainly involves a Master-Detail relationship.
2. Look for independence clues: If the question says the child record should have its own sharing settings, its own owner, or should persist after the parent is deleted, the answer is a Lookup relationship.
3. Many-to-many = Junction Object: If the scenario describes a many-to-many relationship, look for the answer that involves a junction object with two master-detail relationships.
4. Standard objects cannot be detail: If a question asks about making a standard object (like Account or Contact) the child in a master-detail, remember this is not allowed. Only custom objects can be the detail side.
5. Conversion questions: If asked about converting a lookup to master-detail, remember the prerequisite: all existing records must have a non-null value in the lookup field.
6. Watch for "required" vs "optional": A master-detail field is always required. If the scenario allows the field to be optional or blank, it must be a Lookup.
7. Roll-up summary fields are exclusive to Master-Detail: This is one of the most heavily tested points. If a question asks how to declaratively create a roll-up summary, the relationship must be master-detail.
8. Reparenting trap: By default, master-detail relationships do not allow reparenting. If the question mentions changing the parent, check whether "Allow Reparenting" is an option or if a Lookup is more appropriate.
9. Count the relationships: Remember the limits — 2 master-detail and 40 lookup per object. If a question involves more than 2 parent dependencies, at least some must be lookups.
10. Eliminate wrong answers first: Many questions present four options mixing relationship types. Use the key differentiators (cascade delete, roll-up summary, ownership, required field) to quickly eliminate incorrect choices.
11. Security inheritance is a common trap: Questions about OWD, sharing rules, or record-level access on child objects often hinge on whether the relationship is master-detail (inherited) or lookup (independent). Pay close attention to security-related keywords.
12. Practice scenario-based thinking: The exam rarely asks "What is a master-detail relationship?" directly. Instead, it presents real-world scenarios and asks you to choose the correct relationship type. Practice mapping business requirements to relationship characteristics.
Summary
Master-Detail and Lookup relationships are foundational building blocks of the Salesforce data model. Master-Detail creates a tight parent-child bond with cascade delete, inherited security, and roll-up summary support. Lookup creates a flexible, loosely coupled association where child records maintain their independence. Knowing when to use each — and understanding their behavioral differences — is essential for passing the Platform Developer 1 exam and building effective Salesforce applications.
🎓 Unlock Premium Access
Salesforce Certified Platform Developer I + ALL Certifications
- 🎓 Access to ALL Certifications: Study for any certification on our platform with one subscription
- 2750 Superior-grade Salesforce Certified Platform Developer I practice questions
- Unlimited practice tests across all certifications
- Detailed explanations for every question
- PD1: 5 full exams plus all other certification exams
- 100% Satisfaction Guaranteed: Full refund if unsatisfied
- Risk-Free: 7-day free trial with all premium features!