In Salesforce, the Data relationship between objects is quite a tricky topic. In this article, we would be discussing the types of relationships in Salesforce and which relationship should be used when extending your Salesforce data model.
A relationship is a two-way association between two objects. Relationships associate objects with other objects. Create relationships to link objects with each other, so that when your users view records, they can also see related data. You can define different types of relationships by creating custom relationship fields on an object.
Even without relationships, we could build out as many custom objects as we wish, but they’d have no way of linking to one another. With relationships, we can make such a connection and we can also display data about other related objects & records on a particular record’s detail page.
Relationship: dependency of values
To derive values and to eliminate repetition and inconsistency
We can define a relationship between two objects through the use of common fields on the platform; we can define relationships between objects by creating a relationship custom field that associates one object with another.
A relationship field is a custom field on an object record that contains a link to another record. When we place a relationship custom field on an object, we are effectively creating a many-to-one relationship between the object on which the relationship field is placed. Fortunately for us, many-to-many relationships allow for greater flexibility.
There are different types of relationship fields, each with different implication, those four types are:
1. Hierarchical relationship → 1:1
2. Look-up relationship → 1:M
3. Master-details relationship → 1:M
4. Many-to-many relationship → M:M
Want to enhance your skills in dealing with the world's best CRM, enroll in our Salesforce Online Course |
This type of relationship is a special lookup relationship available only for the user object. It allows users to use a lookup field to associate one user with another that does not directly or indirectly refer to itself. For example, you can create a custom hierarchical relationship field to store each user’s direct manager.
It is a one-to-one relationship, it can be created only with one user object in the approval process so as to assign who is reporting to whom.
One to Many relationships links one record to another record.
Can link standard to custom objects and vice versa, or link to the same object type (parent account, for instance).
The field of objects gets its values from the record of objects, if the record in object1 gets deleted the field becomes empty in objects2.
In a 1-to-many relationship, if we delete the parent record, the child record will not get deleted
Creating look-up relationship:
It is similar to a look-up relationship, but if a parent record is deleted, the child record also will be deleted automatically.
Every child record should be associated to a parent, child record can’t exist individually.
Manual sharing and sharing rules are not allowed for the child record.
We can’t have standard objects on the child side, only custom objects are allowed.
This is a parent-child relationship where master-objects control certain behaviors of the detail-object.
Software candidates and jobs applied objects
Click on username → setup → app setup → create → objects → click on jobs applied object → go to custom fields and relationship click on new → master details relationship (select) → next → related to the candidate → next → field label candidate → field name candidate → child relationship name jobs-applied1 → next → next → save.
Now, that the master-detail relationship for the candidate object is created, the candidate object acts as a master object now. We can create a roll-up summary for any field in candidate master objects.
A roll-up summary field calculates values from related records, such as those in a related list. You can create a roll-up summary field to display a value in a master record based on the values of fields in a detail record. The detailed record must be related to the master through a master-detail relationship.
The read-only field is used to display the count of the child records as sum, count, min, max of a field in the particular child object.
This will only enable the master-detail relationship for the master.
Begin creating your roll-up summary just as you create any other custom field:
Master object candidate
Summarized object jobs applied
Select roll-up type
1. Count
2. Sum
3. Min field to aggregate none
4. Max ↓
Next → save.
Sum, min, max are only done on currency, number, dates
Related Article: Salesforce Interview Questions & Answers |
The difference between save and quicksave
→ Save: Save completes the save process and closes the Page Layout Edit window. After saving, it will take you back to the objects page
→ Quicksave: Quick Save allows you to save your changes, but keeps you on the Page Layout Edit screen. Then in another tab, you can refresh the view and see your changes will take place. After saving, it will stay on the list page.
This relationship cannot be created directly, it comes as a result of two master objects having a common child object.
The child objects are known as function objects and the relationship between the two master objects is known as many-many relationships.
Ex: A single position can be found on multiple websites and on one website we have multiple positions.
Junction Object: In Salesforce, a Junction Object is a custom object with two master-detail relationships to two different record types. It is used to represent a many-to-many relationship in which several junction objects can link one instance of a record to many children, and each child can equally be linked to.
Related Article: Learn Salesforce Tutorials |
First, create junction object
Setup → create → object → new custom object → student tech → data type auto number → display format ju-{000} → starting no1 → save
Create MDR between student techs to student (master)
Related list label student
↓
Save and new
Create MDR between student techs to technology (master)
Related list label technology
↓
Save
Formula Relationship
One field computes its values from another field of the object
e.g.: age, simple interest and return on investment
DOB 10-10-2000
Age 10-10-2000 → formula field
Formula:
Formula is a read-only field which is used to derive a value based on expressions.
e.g.: city &“,”& company
↓
Hyd, TCS
For e.g.: the return type is numeric, the available operator is +,-,x,%
If return type character ”&” is the only operator ‘&’ and is used to concatenate strings
From the custom field
↓
Go
↓
Choose a data type formula
→ Returned value type
→ Character
Field label
Field tab name
Text=city &“”& company → next → next → save
→ HydTcs
A formula result can be of only 6 data types
1. Currency
2. Date
3. Date time
4. Text
5. Number
6. Percent
We have come to the end of this guide. We hope that you have clearly understood the types of object relationships in Salesforce. Still, if you have any queries, please feel free to drop your question in the comment section. We will resolve it as soon as possible.
Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
Name | Dates | |
---|---|---|
Salesforce Training | Aug 05 to Aug 20 | |
Salesforce Training | Aug 08 to Aug 23 | |
Salesforce Training | Aug 12 to Aug 27 | |
Salesforce Training | Aug 15 to Aug 30 |
Arogyalokesh is a Technical Content Writer and manages content creation on various IT platforms at Mindmajix. He is dedicated to creating useful and engaging content on Salesforce, Blockchain, Docker, SQL Server, Tangle, Jira, and few other technologies. Get in touch with him on LinkedIn and Twitter.
1 /15
Copyright © 2013 - 2023 MindMajix Technologies