Salesforce is a cloud-based online solution for customer relationship management (CRM). Salesforce provides all the departments - like marketing, sales, commerce, and service - with a shared view of our customers in a single integrated CRM platform.
Relationships in Salesforce
A relationship is a two-way association between two objects. We create relationships to link objects with each other so that when the users view records, they can also see related data. Avoiding data redundancy and data inconsistency, we are in need of relationship. We can define different types of relationships like Master-Detail Relationship, Lookup relationship and Many to Many Relationship.
Master-Detail Relationship
A master-detail relationship is a parent-child relationship where the master is like a parent and detail is like a child in which master object controls some behaviors of the detail object. Also, when a Master object record is deleted, the detail object related to it also gets deleted.
Lookup relationship
Lookup Relationship is nothing but creating a relationship between two same objects. This Lookup Relationship is a Self-relationship to the same object.
Many to Many Relationship
A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vice versa.
In this article, we will learn how to create a Master-Detail Relationship between student and department objects in SalesForce.
The prerequisites are for creating a Master-Detail Relationship in SalesForce are - Register a Salesforce Free Trial account using the following
link.
Step 1
Log into your Salesforce account and click "Setup".
Step 2
Click the Object Manager and create the Department, Studentobject (custom object – Refer
How to create custom object) and create the Department custom fields (DepID, DepName, DepIncharge, DMobno) and student object custom fields (StudID, SName, SMobno, SEmail)(Refer
How to create custom Field).
Step 3
After creating the Student and Department objects, now we can create Master-Detail Relationship between Department and Student objects.
Select a Student object, Select the Field & Relationships in the details tab and click New.
Select the Master-Detail Relationship and click Next.
Select the related to object as Department and click Next.
Enter the Field Label and Name for the lookup and click Next.
Visible all the field level security and click Next.
Now, the Master-Detail Relationship is created between the Department and Student objects.
Step 6
Now, we can verify the Master-Detail Relationship between Department and Student objects through App Launcher.
Select the New Department from Departments tab.
Enter the Department details and click Save.
One more Department was created with the new Department is also added and the list of added Departments is mentioned below.
Select "New Student" from Students tab,
Enter the Student details and select the studdep (master-detail relationship) as the list from Department object and click Save,
One more student is also created and the added students list is,
Summary
Now, you have successfully created and tested the Master-Detail Relationship between Department and Student objects in SalesForce environment.