25
Relationships in Salesforce
We have already talked about Objects (Standard & Custom both). I stated that a Salesforce Org can have multiple objects and in many cases, objects need to be connected with each other.
This connection that we are talking about is called Relationship of Objects.
This connection that we are talking about is called Relationship of Objects.
A two-way linking of objects in Salesforce is called an object relationship. An object relationship is salesforce can be created by creating a custom field.
Say, for example, you have created a relationship between Account and Contact objects. Now when you access the child object, you can also view and access the shared details of parent object.
Normally, in Contact Object, you can see a field named Account Id. This represents relationship between the Contact records and associated Account records.
Say, for example, you have created a relationship between Account and Contact objects. Now when you access the child object, you can also view and access the shared details of parent object.
Normally, in Contact Object, you can see a field named Account Id. This represents relationship between the Contact records and associated Account records.
The most commonly talked about relationship types in Salesforce are -
In this relationship, both the related objects are loosely coupled, i.e. the deletion operation on one object will not affect another object. If one gets deleted, other will remain as it is, doesn't matter if the deleted object is Parent or Child.
To create a lookup relationship, create a new custom field and select Look Up from the option -


In this relationship, one object is a Master and the other is detail or child. Unlike Look-up relation, the objects here are tightly coupled.
We can use this relationship when we need two objects to be closely dependent.
We can use this relationship when we need two objects to be closely dependent.
To create a Master-Detail relationship, open the object where you want to create and click on 'New' in fields tab.
A maximum of 2 MD relationships can be created per object.
The Master Detail relationship allows you to have Roll-up fields too. However, the roll up field can only be created on master side.
Learn more about Salesforce relationships here -
Salesforce Relationships
Salesforce Relationships
25