Members

Different Types of Object Relationships in Salesforce

Understanding data relationships between objects in Salesforce can be a challenge. You might have to decide which relationship types to utilise and expand the Salesforce data model if a business situation calls for the creation of a custom object.

This is an important concept to understand as it helps you choose the correct relationship type for a scalable data model.

Types of object relationships in Salesforce

Master-Detail Relationship:

The master object controls the dependent child object's behaviour in a parent-child relationship.
There can be just one parent and many children in a 1:n relationship and a master-detail object has a 1:n relationship.
The most important factor you need to understand is that the master field cannot be empty since it is a controlling object.
The dependent object's related fields are likewise destroyed when a record or field in the master object is deleted.
An example of this is a cascading delete.
The owner, sharing, and security settings for dependent fields are inherited from their master.
As long as the standard object is the master in the relationship, you can build master-detail relationships between two custom objects or between a custom object and a standard object.

Master-Detail relationship behaviour:

A connected child or detail record is automatically destroyed when a master record is erased.

Both objects in a master-detail connection are tightly related to one another.

The detail records' sharing and security settings inherit their master settings.

This relationship can exist between custom objects as well as between standard and custom objects.

When constructing a relationship between standard and custom objects, keep in mind that the standard object must be on the master side.

In master-detail relationships, roll-up summary fields can also be used to derive values from child records using aggregation functions like Count, Sum, Min, and Max.

On the page layout for the detail record, the master-detail field is necessary.

A maximum of two master-detail relationships can be established for each object.

Lookup relationship:

When you wish to link two objects together without depending on their parent object, you utilise lookup relationships.
You might think of this as a type of parent-child connection, similar to the master-detail relationship, where there is only one parent and many children, or a 1:n relationship.
The only distinction between the master-detail and lookup relationship is that, despite being the controlling field, the lookup field in the child object will not be deleted automatically when a record is deleted.
There will be no cascading delete in this situation, and the records in the child object won't be affected.
No child fields will take on their parent's ownership, sharing, or security preferences.

Look-Up relationship behaviour:

Objects are loosely linked in this relationship.

In a lookup relationship, we are unable to generate a roll-up summary field.

In look-up relationships, parent and child records each have unique sharing and security settings.

Although the Look-Up relationship field is not required by default in Lightning, we can click the option to make it so.

A maximum number of 40 look-ups are permitted for each object.

Junction Relationship(Many-to-Many):

When two master-detail relationships are needed to be established then this type of relationship occurs.
By connecting three custom objects you can create two master-detail relationships.
In this case, there will be two master objects and a one-third object that is reliant on the other two.
To put it in another way, It will be a child object for both the master objects.

Self-relationship:

Simply put, self-relationship means developing a relationship with oneself.
In this relationship, we can use look-up to associate an object with itself.
Example: The Parent Account field on the Account object displays the relationship between different Account objects.

External relationship:

With Salesforce Connect, a brand-new field type was created.
The external relationship field is used to connect one external object to another external object.
It supports common look-up relationships that employ an association's 18-character Salesforce Id.

Hierarchical relationship

A specific kind of lookup relationship is available for the user object only.
In this type of object relationship, a user is connected to another user who does not make any reference to himself directly or indirectly.
For instance, we can store the user's direct manager by developing a unique hierarchical relationship field.

Always bear in mind:

The master-detail relationship is lost at the moment of deletion. It is not restored unless the child/detail record is restored. If we remove a child record and then restore it from the recycle bin only then the child/detail record will be restored.

If there is no roll-up summary field available, we can convert a master-detail to a look-up and a look-up to a master-detail if the lookup field in every record has a value.

To summarize, Salesforce chooses which fields are necessary, shared, and deleted while creating a page layout based on several types of relationships between the objects. The master-detail relationship fields are necessary for the detail object's page layouts. The Lookup relationship does not support the creation of Roll-up summary fields. A custom object in Salesforce called Junction is used to create many-to-many relationships. A child Standard, Custom, or External Object is connected to the Parent External Object via an External Relationship. In hierarchical connections, a user is connected to another user who does not make any references to it directly or indirectly. In this way, different types of Salesforce relationships can be used to achieve various goals like viewing records and seeing as well as accessing data at the same time.



Founded in 2015, Premium Learning Systems have established a strong foothold in the domain of training with our phenomenal results. Till date, more than 25,000 students have been a part of this journey that has enhanced their skills and enlightened their career paths.
We offer a Career Accelerator Program (C.A.P.) which is an intensive 12-week online training program conducted by Premium Learnings to enable the professionals for the Premium-IT industry even if they are coming from a non-IT background.
For any Queries Contact us: - https://premiumlearnings.newzenler.com/contact-form/
If you are interested in Salesforce, you can join our Career Accelerator Program (C.A.P).
Click the link and join the course: https://www.premiumlearnings.com/cap/
Have you completed your graduation and are still looking for a job in IT? Or do you want to switch to a career in IT? You can learn about how to do so by reading the details here:
https://www.premiumlearnings.com/blog/reasons-to-switch-to-an-it-job

Views: 4

Comment

You need to be a member of On Feet Nation to add comments!

Join On Feet Nation

© 2024   Created by PH the vintage.   Powered by

Badges  |  Report an Issue  |  Terms of Service