In this blog post, I will explain some important points to remember when you are choosing an appropriate data model in Salesforce and I will try to explain them with the help of examples. Whenever we are setting up an application in Salesforce, we need to setup a data model which refers to the use of objects and fields.It can consist of standard and custom objects, fields and different relationship types.
Data Modeling in Salesforce:
Standard Objects: Standard objects include Account, Contact, Cases and Opportunity are provided by Salesforce.
Custom Objects: Custom objects can be used to store information specific to a company’s requirement such as properties.
Schema Builder: Schema Builder allows viewing and setting up the data model quickly and efficiently.
Relationships: Different relationship types can be used to set up the data model,such as lookup and master-detail.
Salesforce Data Model:
Standard Objects: standard objects such as Account,Contact, Lead and opportunity are included in Salesforce by default. These are the objects which are provided by Salesforce out-of-the-box.
Custom objects: custom objects can be created to store specific information that cannot be stored in standard object. If your company needs to store specific information related to Patient Insurance, you can create a Custom object.
Standard fields: Standard fields such as Name, ID and CreatedDate are created by default. Whenever you create a custom object, these are the standard fields that are added by salesforce. Every standard object in Salesforce also contains the same field.
Custom fields: Create custom fields of different data types to store additional information.If you want to store information related Employee’s Birth Date and Address, you can create custom fields in order to store this data.
Lookup relationships: This is a loosely coupled relationship between two objects. It is a one-to-many relationship. In the case of lookup relationship, when you delete a parent,child records will not get deleted.
Master-Detail Relationships: This is a tightly coupled relationship between two objects. In the master-detail relationship, when you delete the parent, child record will automatically get deleted and also the sharing setting of the child records are controlled by the parent record.
Many-to-Many relationships: In order to create a many-to-many relationship between two objects, we create a Junction object.
Data Model: Create objects, fields and relationships to represent the data in the database.
- A data model is a way to represent data in a database consisting of tables with columns and rows.
- Objects represent tables, fields represent columns and records represent rows in Salesforce.
- A data model can represent a collection of objects and fields in an app and how they are related to one another in an app.
- Specific relationships can be defined among the objects in an app to create the data model.
- The data model can be examined by navigating to ‘Schema Builder’ in Setup.
Choosing a Data Model:
- A data model is typically created for a custom application in Salesforce.
- It can consist of standard and custom objects, custom fields and relationships.
- Different relationships like lookup, master-detail and many-to-many relationships can be utilized in a data model.
- You can use Schema builder to view the data model as well as to create objects, fields and relationships.
How to access the Data Model?
In Salesforce, Object Manager in Setup and Schema Builder are tools used to create Data models. Although you can use Schema Builder to configure objects, fields and relationships, it has certain limitations.
Object Manager still serves as the complete and most comprehensive tool for managing data models involving both standard and custom objects.
In order to access Object Manager, go to Setup and click on the Object Manager tab in the navigation bar.
Enter Object Manager in the Quick Find text box.
Schema Builder can be accessed from Object Manager, or it can be found by entering “Schema Builder” in the Quick Find text box in Setup.
It is a tool used for creating and viewing data models or customizing them according to requirements.
Abilities of Schema Builder:
- It provides the ability to view the relationship structure and fields that are available for each object in Salesforce.
- It allows identifying the relationships between the objects and creating new custom objects and fields to customize and design the data model.
- You can use Schema builder to create objects, fields and relationships also.
- It provides the ability to add custom objects, lookup relationships, master-detail relationships and all custom fields except Geolocation.
- Custom fields added using Schema Builder are not added automatically to page layouts.
- Roll-up summary fields can be added to an object if it is the master in a relationship.
- Objects can be hidden on the canvas, but fields cannnot be hidden.