Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Topics:

● 1:1, 1: Many, Many to Many Relationships


● Lookup Relationships
● Master Detail Relationship (Rollu+p Summary)
● Many to Many Relationship (Junction Object)
● Self-Relationship
● Hierarchical Relationship
● External Relationships
● Indirect lookup relationship
● Special Relationship: Account and Contact, Account and Opportunity Relationships
1: Many, Many to Many Relationships
Examples:
● 1:1- One school can have only one Principal.
● 1: Many (or Many:1)- One Class may have multiple Students
● Many to Many- Trainings and Students- Students can enroll to multiple trainings and one
training can have multiple students.
Look up vs Master Detail Relationships:
Example: Master Detail Relationship:
● Let’s Consider Class Object and Students Object
● Student can not exist without a Class
● Student can have only one Class

Example: Lookup Relationship:


● Let’s Consider Class Object and Teachers Object
● Teacher can exist without a Class (may be temp teachers etc.)

Category Lookup Relationship Master Detailed Relationship


Type Loosely coupled Tightly coupled
Child Deletions Childs not deleted, when parent Childs deleted, when parent deleted
deleted
Child without Parent Yes No
Parent Requirement No Yes
Rollup Summary No Yes
On Page Layout of Child No Yes

Standard Object Behavior SO can be on the child of a Standard object record cannot be a
custom object child.
Ownership of Child 7 Controlled by Parent
Limit 40 2

To prove Standard object cannot be the child of Master Detail Relationship, please see below, there is
no Master detailed relationship option for standard objects. Hence, proved….!
Example: Many to Many Relationship (Junction Object)
● Let’s Consider Training Object and Students Object
● One Student can enroll into multiple Trainings
● One Training can have multiple Students enrolled.

Important Notes on Junction Object:


- Junction Object will inherit sharing and security from master object on which FIRST master look
up relationship is created
- Junction object record will be deleted when either parent is deleted.
Ok, what happens if we implement many to many relationships with lookup instead of Master
Detailed?
- It will achieve same functionality, BUT
o Child records will present and will utilize storage when parent records are deleted.
Training-Student record doesn’t make sense if student is not present or Training is not
present, got it?
Self-Relationship:
A self-Relationship is a lookup relationship to the same object. Contact object has self-lookup as
below:
Hierarchical Relationship:
This is a unique lookup relationship that only the USER object can have. It enables users to associate
one person with another without referring to themselves directly or indirectly using a lookup field.
See below, there is no Lookup/Master Detailed relationship on User Object.
External Lookup Relationship Salesforce Standard/Custom Object > External Object, this also behaves
similarly to Lookup Relationships. Creates a relationship that links this object to an external object
whose data is stored outside the Salesforce org.
Indirect lookup relationship:
An indirect lookup relationship is a new field type introduced with Salesforce Connect. It links an
external object to a standard or custom object in the same way that a regular lookup relationship
links standard or custom objects.
● An indirect lookup relationship utilizes either a standard or custom object as a parent, and an
external object as a child.
● In an external lookup, the situation is reversed: the external object becomes the parent record

Account and Contact, Account and Opportunity Relationships.


Let’s look at schema diagram: It shows look up relationship, really? Let’s test!!!

● Account - Contact and Account – Opportunity have a Special relationship. Account is a parent
of both Contact and Opportunity. Most people say either master-detail or look up!!
● They behave as master detail in business logics but on UI it is a lookup relationship.
● You can create a contact/Opportunity without filling the accounti.e., it shows that there is a lookup relationship
between account and contact/Opportunity.

● If you have created a contact/Opportunity with an account and you delete that account then
contact/Opportunity will be deleted, this shows that it is in Master-Detail relationship.

You might also like