- Salesforce Tutorial
- Salesforce - Home
- Salesforce - Overview
- Salesforce - Architecture
- Salesforce - Environment
- Salesforce - Sales Cloud
- Salesforce - Service Cloud
- Salesforce - Navigating Setup
- Salesforce Objects
- Salesforce - Standard Objects
- Salesforce - Custom Objects
- Salesforce - Master Detail
- Salesforce - Lookup Relationship
- Salesforce - Schema Builder
- Data Security
- Salesforce - Control Access Org
- Salesforce - Control Access Objects
- Salesforce - Control Access Fields
- Salesforce - Control Access Records
- Salesforce - Create a Role Hierarchy
- Salesforce - Define Sharing Rules
- Process Builder
- Automate Business Processes
- Salesforce - Importing Data
- Salesforce - Exporting Data
- Salesforce - Reports
- Salesforce - Dashboards
- Salesforce - Using Formula Fields
- Salesforce - Visualforce Pages
- Salesforce - Variables & Formulas
- Salesforce - Standard Controllers
- Salesforce - Records, Fields & Tables
- Salesforce - Using Forms
- Salesforce - List Controllers
- Salesforce - Static Resources
- Salesforce Useful Resources
- Salesforce - Quick Guide
- Salesforce - Useful Resources
- Salesforce - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Salesforce - Master Detail Relationship
Unlike the relationships in relational database, the relationships in Salesforce are not through Primary and Foreign Keys. The relationships are maintained by using the Relationship Fields. It is a custom field which links one object record to another. Through the creation of relationships, we can display the data of all the related records in the record's details page.
The Master Detail relationship is used when we want to control the display of detail records based on the value in the master record. For example, in the courier company model a delivery schedule is always linked to a delivery location. If we remove a delivery location from our list, then all the related delivery schedules should also be eliminated. Such a dependency can be achieved through Master-detail relationship between the sales force objects.
Features of Master-Detail Relationship
In this section, we will discuss the features of Master-detail Relationship. The features are listed below −
Deleting a Master Record, deletes all the detail records.
A detail record cannot be created without a Master record.
The permission on the detail record cannot be set. It inherits the permission from the master record.
The detail record also inherits the sharing rule from master records.
Both the master and detail records are automatically included in the report record types.
Creating Master-detail Relationship
In the courier company example, we will consider the relationship between delivery location and delivery schedule. There is a many-to-one relationship between the delivery schedule records and the delivery location record.
Following are the steps followed to create this relationship −
Choose the Relationship Type
In setup home, find the object named Delivery Schedule. In it under the Custom Fields and Relationships related list, click New. Choose the Master-detail Relationship as shown in the screenshot below.
Choose the Related Object
In the next step, select the object with which this relationship will be created. We choose DeliveryLocation.
Name the Relationship and Field
In this step, enter the Relationship Name as well as the name of the Field.
Add field to page layout
In the Next step we accept the defaults and move on to add the reference field to the page layout.
Add Custom Related Lists
Next, we specify the title for the related list that is associated layout with the parent.
This completes the creation of Master-Detail relationship between DeliveryLocation and Deliveryschedule.