Learn All About Data Modeling in Salesforce
Introduction
A data model is a way to store/represent data in a database consisting of tables with columns and rows.
In Salesforce, data is stored in the form of tables where the objects represent tables, fields represent columns and records represent rows in Salesforce.
Objects and Fields in Salesforce
There are mainly two types of objects and fields present in Salesforce:
- Standard object and fields
- Custom object and fields
-
Standard Object and Fields
These are the objects and fields which are provided by Salesforce known as standard objects such as account, contact, opportunity, lead, etc.
-
Custom Object and Fields
Custom objects and fields are those which are created by the admin to store the information as per business requirements. We can also create custom fields on the Standard object as per the requirement. The API name of custom objects and fields is represented by append __c.
For example, a custom object’s name is Student then its name will be Student __c.
Relation between objects in Salesforce.
Don't forget to check out: Safer Data Migration With Salesforce Audit Fields
How to Create a Custom Object and Fields in Salesforce
Firstly login to your Salesforce org then Navigate.
Create a Custom Object
Setup > object Manager > create > custom object > fill required details > save.
Create Custom Fields
Setup > object Manager > (click the object in which you want to create custom field) > Fields & Relationships > New > choose data type > fill required details > check field security and Save.
Relationships in Salesforce
There are commonly three types of relationships present in Salesforce between the object:
- Master-detail Relationship
- Lookup Relationship
- Many to many Relationships
-
Master-Detail Relationship
This is a one-to-many type relationship, In which the master object is the parent object and it is mandatory while creating records on the child object. In the mater details relationship, the child object inherited the security settings from its parent object. It is a strongly coupled relationship that means if the master object record is deleted then the associated child records will be deleted automatically. The rollup summary feature is available only for the master-detail relationship. In mater details relationship the standard object can not be a child of a custom object.
-
Lookup Relationship
This is also a one-to-many type relationship, In which the parent object is loosely coupled with the child object. In the lookup relationship, the parent is not mandatory while creating child object records. The roll-up summary feature is not available in this relationship and the standard object can be a child of a custom object.
Check out another amazing blog by Arun here: Salesforce Loops in Apex | The Developer Guide
-
Many to many Relationship
To establish the many to many relationships, first, we have to a custom object, and this custom has two master-details relationships.
Considerations for relationships in Salesforce
An object can have a maximum of 40 relationships including a maximum of two master-detail relationships.
Responses