A master detail relationship salesforce is a parent-child relationship where the child record cannot exist without its parent. This relationship type enforces data integrity through cascade deletion, security inheritance, and mandatory parent association. Understanding master detail relationships is essential for Salesforce admins and developers building robust data models.
In Salesforce, object relationships define how records connect and interact with each other. There are four primary relationship types, with master-detail being the most restrictive and powerful for maintaining data consistency.
Master Detail Relationship Salesforce: Core Characteristics
A master detail relationship salesforce implementation requires understanding these fundamental characteristics:
- Mandatory parent association: Child records must have an associated parent record
- Cascade record-level security: Child records inherit sharing settings from parent
- Cascade deletion: Deleting parent automatically deletes all child records
- Roll-up summary field support: Parent can aggregate child record data
- Standard object limitations: Standard objects cannot be detail (child) objects
- Maximum limit: Up to 2 master-detail relationships per object
- Reparenting capability: Child records can be moved between parents (with proper permissions)
Mandatory Parent Association
In a master detail relationship salesforce configuration, the child object (detail) must always have an associated parent record. This field appears as required on the child record’s page layout and cannot be left blank during record creation.
Cascade Record-Level Security
Child records inherit sharing settings from their parent record. If a user has access to view a parent record, they automatically gain access to view associated child records. This inheritance applies to:
- Organization-wide defaults (OWD)
- Sharing rules
- Manual sharing
- Role hierarchy access
Cascade Deletion Behavior
When a parent record is deleted, all associated child records are automatically deleted. This cascade deletion cannot be prevented and occurs immediately. Consider this carefully when designing your data model, especially for objects containing critical business data.
Roll-up Summary Fields
Master-detail relationships enable roll-up summary fields on the parent object. These fields automatically calculate values from child records using functions like:
- COUNT: Number of child records
- SUM: Total of numeric field values
- MIN/MAX: Minimum or maximum values
- AVG: Average of numeric field values
Object Relationships in Salesforce: Complete Overview
Salesforce supports four types of object relationships, each serving different business requirements:
1. Master-Detail Relationship
The most restrictive relationship type, enforcing tight coupling between parent and child objects. Best for scenarios where child records have no business meaning without their parent.
2. Lookup Relationship
A flexible relationship where the parent is optional. Key characteristics include:
- No parent required for child record creation
- Optional relationship field
- No security inheritance
- No cascade deletion
- No roll-up summary field support
- Up to 25 lookup relationships per object
3. Many-to-Many Relationship
Created using a junction object that connects two parent objects through two master-detail relationships. The junction object serves as the bridge, enabling complex data relationships.
Junction Object Implementation
- Junction object has two master-detail relationships
- Each parent object can relate to multiple records of the other parent
- Junction object inherits security from both parents
- Deleting either parent removes associated junction records
4. Hierarchical Relationship
A special lookup relationship available only on User and custom objects, allowing records to relate to other records of the same object type. Commonly used for organizational structures.
Salesforce Buyer Relationship Map: Business Context
A salesforce buyer relationship map visualizes the connections between different stakeholders in your sales process. This mapping helps sales teams understand decision-making hierarchies and influence patterns within prospect organizations.
Implementing Buyer Relationship Maps
Use master-detail or lookup relationships to model buyer relationships:
- Account (Company) → Contact (Stakeholders)
- Opportunity → Contact Role (Buying committee members)
- Custom objects for complex relationship tracking
Best Practices for Buyer Relationship Mapping
- Define clear role categories (Decision Maker, Influencer, User, Gatekeeper)
- Track relationship strength and communication frequency
- Use custom fields to capture influence levels
- Implement validation rules to ensure data quality
Master-Detail vs Lookup: When to Use Each
| Feature | Master-Detail | Lookup |
|---|---|---|
| Parent Required | Yes (mandatory) | No (optional) |
| Security Inheritance | Yes | No |
| Cascade Deletion | Yes | No |
| Roll-up Summary | Yes | No |
| Standard as Child | No | Yes |
| Relationships per Object | 2 maximum | 25 maximum |
Configuration Best Practices
Planning Your Relationship Strategy
Before creating master-detail relationships, consider:
- Data lifecycle: Will child records ever need to exist independently?
- Security requirements: Should child records inherit parent security?
- Deletion impact: Can you afford to lose child records when parents are deleted?
- Reporting needs: Do you need roll-up summary calculations?
Governor Limits and Considerations
- Maximum 2 master-detail relationships per object
- Roll-up summary fields count toward custom field limits
- Cascade deletion affects DML operation limits
- Large data volumes may impact performance during reparenting
Security Model Impact
Master-detail relationships significantly impact your org’s security model:
- Child record access determined by parent record access
- Profile and permission set configurations apply to parent object
- Sharing rules on parent automatically extend to children
- Field-level security inherited from parent object settings
Common Implementation Scenarios
Invoice and Line Items
Classic master-detail use case where Invoice (master) contains multiple Line Items (detail). Line items cannot exist without an invoice, and deleting an invoice should remove all associated line items.
Project and Tasks
Project management scenarios where Tasks (detail) belong to specific Projects (master). Tasks inherit project security settings and are automatically removed when projects are deleted.
Survey and Responses
Survey applications where individual Responses (detail) belong to specific Surveys (master). Responses have no meaning without their parent survey context.
Troubleshooting Common Issues
Cannot Delete Master Record
Error occurs when trying to delete a master record with associated detail records in certain scenarios:
- Detail records in different sharing contexts
- Workflow rules preventing deletion
- Apex triggers with deletion restrictions
Solution: Delete detail records first, or modify sharing/trigger logic to allow cascade deletion.
Reparenting Failures
Reparenting may fail due to:
- Insufficient permissions on new parent
- Validation rules on detail object
- Roll-up summary field calculations
Solution: Verify user permissions and temporarily disable validation rules during data migration.
Performance Issues
Large master-detail hierarchies can cause performance problems:
- Slow page loads due to related list queries
- Timeout errors during cascade operations
- Roll-up summary calculation delays
Solution: Implement selective queries, use asynchronous processing for bulk operations, and consider lookup relationships for large datasets.
Frequently Asked Questions
What is the difference between master-detail and lookup relationships in Salesforce?
Master-detail relationships require a parent record and enforce cascade deletion and security inheritance. Lookup relationships are optional connections where child records can exist independently, with no security inheritance or cascade deletion.
Can standard objects be used as detail objects in master-detail relationships?
No, standard objects cannot be detail (child) objects in master-detail relationships. However, standard objects can serve as master (parent) objects. This limitation protects Salesforce’s core data model integrity.
How many master-detail relationships can one object have?
Each object can have a maximum of 2 master-detail relationships. This limit prevents overly complex data models and ensures system performance. If you need more parent relationships, consider using lookup relationships instead.
What happens to child records when a parent record is deleted?
All child records are automatically deleted when their parent record is deleted. This cascade deletion cannot be prevented and occurs immediately. Ensure you have proper backup strategies for critical data.
Can you create roll-up summary fields on lookup relationships?
No, roll-up summary fields are only available on master-detail relationships. The tight coupling in master-detail relationships ensures data consistency required for accurate roll-up calculations. For lookup relationships, use Process Builder, Flow, or Apex for similar functionality.
How do you convert a lookup relationship to master-detail?
First, ensure all child records have populated lookup fields (no null values). Then, edit the relationship field and change the type to Master-Detail. Note that this conversion cannot be undone directly – you would need to create a new lookup field and migrate data.