Master-Detail Relationships in Salesforce represent a tightly coupled association between two objects where one object (the master) controls the behavior of another object (the detail). This relationship type is fundamental to understanding data modeling in the Salesforce platform.
In a Master-Det…Master-Detail Relationships in Salesforce represent a tightly coupled association between two objects where one object (the master) controls the behavior of another object (the detail). This relationship type is fundamental to understanding data modeling in the Salesforce platform.
In a Master-Detail relationship, the detail record inherits its security settings, sharing rules, and ownership from the master record. The detail record cannot exist independently - when the master record is deleted, all related detail records are automatically deleted as well, maintaining referential integrity within your database.
Key characteristics of Master-Detail Relationships include:
1. **Required Relationship Field**: The relationship field on the detail object is always required and must be populated when creating a record.
2. **Roll-Up Summary Fields**: One significant advantage is the ability to create roll-up summary fields on the master object. These fields can calculate COUNT, SUM, MIN, or MAX values from related detail records.
3. **Ownership and Sharing**: The detail record inherits the owner of the master record. You cannot set a separate owner for detail records.
4. **Cascade Delete**: Deleting a master record removes all associated detail records from the system.
5. **Reparenting**: By default, you cannot change the master record once assigned. However, administrators can enable the "Allow Reparenting" option during relationship creation.
When configuring Master-Detail relationships in Object Manager, navigate to the child object, select Fields & Relationships, and create a new Master-Detail Relationship field. The setup wizard guides you through selecting the master object and configuring additional options.
Each object can have up to two Master-Detail relationships, and you can create multi-level master-detail hierarchies up to three levels deep. Understanding when to use Master-Detail versus Lookup relationships is essential for proper data architecture and ensuring your Salesforce implementation meets business requirements effectively.
Master-Detail Relationships in Salesforce
Why Master-Detail Relationships Are Important
Master-Detail relationships are fundamental to Salesforce data architecture. They establish a tightly coupled parent-child relationship between objects, enabling features like roll-up summary fields, cascading delete functionality, and inherited sharing settings. Understanding this relationship type is essential for designing efficient data models and is a frequently tested topic on the Salesforce Administrator exam.
What Is a Master-Detail Relationship?
A Master-Detail relationship is a strongly linked association between two objects where:
• The master (parent) object controls certain behaviors of the detail (child) object • The detail record cannot exist independently of the master record • When the master record is deleted, all related detail records are also deleted (cascade delete) • The detail record inherits sharing and security settings from the master record • The master field on the detail record is always required
How Master-Detail Relationships Work
Key Characteristics:
1. Roll-Up Summary Fields: You can create roll-up summary fields on the master object to calculate values (COUNT, SUM, MIN, MAX) from related detail records.
2. Ownership and Sharing: The Owner field on the detail record is not available. Security access is determined by the master record.
3. Required Relationship: The lookup field to the master object is always required and cannot be blank.
4. Reparenting: By default, you cannot change the master record once saved. However, administrators can enable the Allow Reparenting option to permit this.
5. Standard Object Limitations: Standard objects can only be on the master side of a Master-Detail relationship, never the detail side.
6. Maximum Relationships: An object can have up to two Master-Detail relationships, creating a junction object for many-to-many relationships.
Creating a Master-Detail Relationship
1. Navigate to Setup and open Object Manager 2. Select the object that will be the detail (child) object 3. Go to Fields and Relationships and click New 4. Select Master-Detail Relationship as the field type 5. Choose the master (parent) object 6. Configure field-level security and page layouts 7. Optionally enable Allow Reparenting
Exam Tips: Answering Questions on Master-Detail Relationships
Focus on these key concepts:
• Cascade Delete: Remember that deleting a master record deletes ALL related detail records. This is a common exam scenario.
• Roll-Up Summary Fields: These are ONLY available on master objects in a Master-Detail relationship. If a question asks about calculating totals from child records, Master-Detail is likely the answer.
• Sharing and Security: Detail records inherit their security from the master record. The OWD (Organization-Wide Default) of the detail object is controlled by the master.
• Converting Relationships: You can convert a Lookup relationship to Master-Detail only if all existing records have a value in the lookup field. The reverse conversion is also possible.
• Junction Objects: When you see questions about many-to-many relationships, think of junction objects with two Master-Detail relationships.
• Standard Objects: Standard objects cannot be on the detail side. If a question suggests making Account or Contact a detail object, that answer is incorrect.
• Record Limits: An object can have a maximum of two Master-Detail relationships.
Common Exam Scenarios:
• A business requirement needs to calculate the total value of child records on a parent - use Master-Detail with roll-up summary • Child records should be deleted when the parent is deleted - Master-Detail provides this functionality • Users need different access levels on child records than parent records - this suggests Lookup relationship, not Master-Detail