Data Protection Centre/Salesforce/A Complete Guide to Data Model in Salesforce

Categories

In this article

  • What is Salesforce data model?
  • Salesforce objects and fields
  • Create a custom object in Salesforce
  • Create a custom field in Salesforce
  • Create a relationship between two objects
  • Salesforce Schema Builder
  • Data Management in Salesforce
  • Salesforce data model best practices

A Complete Guide to Data Model in Salesforce

3 Jan 2023
10 min read
Anju George

Article at a glance

Understanding and managing data models in Salesforce is crucial for effective data organization:
  • Salesforce supports various object relationships like lookup and master-detail, each with specific behaviors affecting data integrity and access.

  • Designing and modifying your data model using tools like Schema Builder can simplify complex relationships and enhance data management.

Read more

Salesforce is a leading enterprise software company that provides Customer Relationship Management (CRM) services to over 150,000 businesses globally.  Using the Salesforce CRM platform, you can store, process, and analyze your business-critical data. For this process to run smoothly, the user should be able to view and organize their Salesforce data in an understandable manner. Therefore, it is critical to have a proper Salesforce data model for your organization.

1. What is Salesforce data model?

The Salesforce data model is the way you store and structure your Salesforce data. It is the way in which tables of data are stored in your Salesforce database to make them understandable to anyone who views them. In the Salesforce platform, ‘Objects’ represents database tables, ‘Fields’ represents columns, and ‘Records’ represents rows.

1.1. Why is data model in Salesforce important?

It is important to decide on the Salesforce data model before you start using the platform since the data model has a direct impact on the following in Salesforce: 
  • User experience 
  • Data reporting  
  • Data loading 
  • Ability to automate key business processes 
  • Data access and security policy 

Note: Data model is not the infrastructure or where your data is physically stored; it is how your data is stored and categorized. The Salesforce data model is essentially an aggregation of Salesforce objects and fields, and data modeling is the process of giving structure to your data using objects, fields, and relationships.

2. What are Salesforce objects and fields?

2.1. Objects in Salesforce

Salesforce objects are database tables that allow users to store data specific to their organization. Objects allow you to categorize data in a way that suits your business. Objects in Salesforce can be broadly classified into two categories: 

(a) Standard objects: These are out-of-the-box objects that are created by Salesforce and come pre-built when you implement the Salesforce platform. These are the objects that are necessary to perform basic CRM activities. Some common examples of standard objects are Accounts, Contacts, Opportunities, and Leads. 

(b) Custom objects: These are the objects created by the users if the pre-built standard objects are not enough to meet specific business requirements. Custom objects are used to track and store data that is unique to an organization. When Salesforce is connected to a third-party application (say ChargeBee), the third-party app can also create custom objects on the CRM. 

2.2. How to create a custom object in Salesforce

Required editions: 

Available in both Salesforce Classic (not available in all orgs) and Lightning Experience 

Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions 

User permissions needed: 

To create and edit custom objects: Customize Application 
To create a custom object in Salesforce, follow the below steps: 
  • Step 1: Go to the Setup page. From the top right corner, click Create -> Custom object.

create custom object

Singular and plural labels
  • Step 3: Enter the record name and data type, choose the optional features and other settings according to your business requirements.

optional features and settings

Note: Object creation options that you choose now cannot be changed later.

  • Step 4: Enter the details for the custom object tab. Choose the user profiles and custom apps for which the custom tab should be visible.

enter custom object details

Once the custom object has been created, you can add custom fields to the object. Learn how to add custom fields to an object.

2.3. Fields in Salesforce

Fields in Salesforce are like columns in relational databases. It can store data values that are required for a particular object's record. Every standard and custom object in Salesforce has fields attached to it.

Standard fields, like standard objects, are pre-built in Salesforce and are common to most CRM businesses. Examples of standard fields include company name, contact, account number, status, date, and amount.   

Custom fields are the fields that the users can create in Salesforce to capture information that is not covered by a standard field. You can create custom fields on both standard and custom objects. When you create a custom field, you specify where it appears, what information it contains, what format it should be in (such as number, text, date, or picklist), and who can access and edit it.  

The following are the different types of fields available in Salesforce. 

(a) Identity field 

An identity field is a 15-character, case-sensitive field that is automatically generated for every record. You can find the record’s ID in its URL. 
Example: An account ID looks like 0013000000Gr2sA. 

(b) System field  A system field is a read-only field that provides information about a record from the system, like when the record was created or when it was last modified. 

Example: Fields like Created Date, Last Modified By, and Last Modified Date. 

(c) Name field 

Every record will have a name so that one can distinguish between different records of the same object.  You can use text names or auto-numbered names that automatically increment every time you create a record. 
Example: A contact’s name can be Tom Felton; a support case’s name can be CA-1052. 

(d) Custom field 

Custom fields are the fields that the user creates on standard and custom objects. 
Example: You can create a custom field ‘Birthday’ on your Contact object to store all your contacts’ birthdays. 
Identity, system, and name fields are standard fields that are available for all the objects in Salesforce.  Each standard object comes with a set of pre-built, standard fields. You can also customize standard objects by adding custom fields.  

2.4. How to create a custom field in Salesforce

Required editions: 

Available in both Salesforce Classic (not available in all orgs) and Lightning Experience 
Available in: Contact Manager, Essentials, Group, Professional, Enterprise, Performance, E Unlimited, Developer, and Database.com Editions  
Custom fields aren't available on Activities in Group Edition                                     

User permissions needed:           

To create or change custom fields: Customize Application 
To add field-level security to profiles or permission sets: Manage Profiles and Permission Sets 
To create a custom field in Salesforce, follow the below steps: 
  • Step 1: Go to Setup and click on Fields & Relationships-> Object Manager.

salesforce data model - object manager
  • Step 2: Select the object for which you need to add a custom field. For example, select the custom object ’Property’ that has been created in the previous section. This opens the detail page for that object.

select object
  • Step 3: Click Fields & Relationships from the left panel and click New to create a new field.

fields and relationships
  • Step 4: Choose the field type. This gives you the ability to control the type of data that can be entered into the field. For example, if you create a field with the 'Number’ data type, users can only enter a numerical value to the field. Click Next.

choose field type
  • Step 5: Enter the field details and click Next

enter field details
  • Step 6: Select the profiles to which you want to grant access to this field and click Next. Select the page layouts that should include this field. Click Save.

enter field visibility

select layout
This will create a new custom field. 

 

Note: If you do not want to create a custom object and its fields manually, you can use a spreadsheet to add the object and its fields to Salesforce and populate all its record data. Learn how to do this. 

3. Object relationships in Salesforce

Salesforce allows you to create relationships to link objects with each other, so that when users view records of an object, they can also see the related data from other objects. There are also relationships that are pre-built between two standard objects in Salesforce. For example, there will be many contacts related to a particular account that you have created in Salesforce. When you look at an account record in Salesforce, you can see a section for ‘Contacts’ on the ‘Related’ tab, where you can find all the contacts related to that account.

account-contact relationship
There is also a button that lets you quickly add a contact to the selected account without having to go to the Contact object.  
The Account to Contact relationship is an example of a standard (pre-built) relationship in Salesforce. You can also create custom relationships between objects. 

3.1. Types of relationships in Salesforce

There are two major object relationships supported by Salesforce: 
(a) Lookup relationship
(b) Master-detail relationship

3.1.1. Lookup relationship 

A lookup relationship links two objects together so that you can access or “look up” one object from the related items on another object. It is a loosely coupled relationship, meaning that the child record can exist even without its related parent record. The Account to Contact relationship that was mentioned in the previous section is an example of a lookup relationship present in Salesforce. Sometimes, a contact is associated with a specific account, while at other times, it can act as a standalone object.  
Lookup relationships can be one-to-one or one-to-many. The Account to Contact relationship is a one-to-many relationship since a single account can have multiple related contacts. 

To create a custom lookup relationship between two objects, you will have to add a lookup relationship field on the child (many-sided) object. The relationship field allows users to click on a lookup icon to select a value from a pop-up list. The other object (one-sided object or parent object) is the source of the values in the list. For example, in the below screenshot, ‘Properties’ is the child object and ‘Contacts’ is the parent object. On clicking the ‘Contact’ field (lookup relationship field in this example), a pop-up list of contacts (parent object records) appears from which you can select one. Learn how to create a lookup relationship between two objects. 

lookup relationship

3.1.2. Master-detail relationship

A master-detail relationship is a strongly coupled relationship, where one object is the master, and another is the detail. When a record of the master object is deleted, its related detail records are also deleted. 
The master object controls certain behaviors of the detail object: 
  • The detail object inherits the sharing and security settings of its master object. 
  • The ‘Owner’ field is not available on the detail object and is automatically set to the owner of its associated master record. 
  • A master-detail relationship can be created between two custom objects or between a standard object and a custom object; however, the standard object cannot be on the detail side of a relationship with a custom object. 
  • By default, records cannot be reparented in master-detail relationships. However, admins can allow child records in master-detail relationships between custom objects to be reparented to different parent records by selecting the Allow reparenting option while creating the master-detail relationship. 

  • When a master record is undeleted, all its related detail records also get undeleted.  

Learn how to create a master-detail relationship in Salesforce. 

To learn more about relationships in Salesforce, refer to the Salesforce documentation

3.2. Lookup relationship vs master-detail relationship

Lookup relationshipMaster-detail relationship
Loosely coupled relationship: Deleting a parent record will not delete its child records.
Strongly coupled relationship: If the parent record is deleted, the child record also gets deleted by default.

Roll-up summary field is not available.

Roll-up summary field is available.

Parent record is not required when creating a child record.
Parent record is required to save a child record.
Standard object record can be on the detail side of a lookup relationship with a custom object.
Standard object record cannot be on the detail side of a master-detail relationship.
The ownership of child records is not controlled by the parent object records.
The parent object controls the record ownership of the child records.
There can be a maximum of 40 lookup relationships on an object.
An object can have a maximum of 2 master-detail relationships.

Note: If you’re unsure of what type of relationship to create between two objects, create a lookup relationship since it gives you more flexibility to change things in the future.

3.3. How to create a relationship between two objects in Salesforce

To create a relationship between two objects in Salesforce, follow the below steps:
  • Step 1: Go to Setup and click on Objects and Fields -> Object Manager.

object manager
  • Step 2: From the Object Manager, select the object that will be the child object in the relationship. For example, select the custom object ’Property’ that has been created in the previous section. This opens the detail page for that object.

select child object
  • Step 3: Click Fields & Relationships from the left panel and click New to create a new field.

create new field
  • Step 4: Choose the field type. Select master-detail or lookup depending on what type of relationship you need to build. Click Next.

select field type
  • Step 5: Select the parent object to which you need to relate your object. For example, choose ‘Contacts’.

select parent object
  • Step 6: Enter the field label, field name, and other details. Configure field-level security.

enter field details

field level security
  • Step 7: Select the child object page layouts you would like to display the relationship field on and click Next.

select page layout
  • Step 8: Select the parent object page layouts where you would like to display the related list of child object records. Click Save.

select parent object layout
This will create a lookup relationship between the objects - Contacts and Properties, where ‘Contacts’ is the parent object and ‘Properties’ is the child object. 
When you create a new property record, you can see the relationship field ‘Contacts,’ clicking on which you can choose a contact from the entire list of contacts available. 

lookup relationship
If you go to the Contacts object and select a contact record, you can find all the properties related to the contact under the ‘Related’ tab. You can even create a new property for the selected contact from this page itself.

lookup relationship

4. Edit Salesforce data model using Schema Builder

Schema builder is an in-app tool that lets you visualize and edit your Salesforce data model. It’s useful for designing and understanding complex data models in Salesforce. 

Required editions: 

Available in both Salesforce Classic (not available in all orgs) and Lightning Experience 
Available in all Salesforce editions 

User permissions needed:  To view objects in Schema Builder: Customize Application 

To access schema builder, navigate to Setup and search for Schema builder in the Quick Find box, select the required objects, and click Auto-Layout.  You will see something as shown in the image below. 

schema builder

4.1. Create an object with Schema Builder

You can create objects from the Schema Builder interface itself while designing your Salesforce data model. Follow the below steps to create an object using Schema Builder:
  • Step 1: Click the Elements tab in the left sidebar.

  • Step 2: Click Object and drag it onto the canvas.

create object with schema builder
  • Step 3: Enter your object details. Click Save.

create object with schema builder
Your new object appears in the Schema Builder. You can now create custom fields on the object using Schema Builder.

4.2. Create fields with Schema Builder

To create fields using Schema Builder, follow the below steps:
  • Step 1: Choose a field type from the Elements tab and drag it onto the object that was created in the previous section. You can create relationship fields, formula fields, and normal fields in Schema Builder.

  • Step 2: Fill out the field details and click Save.

create fields using schema builder

If you go to Object Manager, you can now see the newly created object along with all your other objects. 

To learn more about Schema Builder, refer to the following Salesforce documentations: 

5. Data Management in Salesforce

5.1 Import data into Salesforce

Once you have built your data model in Salesforce, you can start adding data to your Salesforce organization. There are three native tools available to import data into Salesforce: 
(a) Data import wizard 
(b) Data loader 
(c) Dataloader.io 
When choosing between the three native tools, you need to consider factors like the Salesforce objects supported by each of these tools and the number of records you need to import. The order in which the records are imported is also important to properly establish relationships between different objects. Parent object records have to be imported before child object records. Record ids are used to associate records with each other. For example, you must import your account records before contact records so that you can use the account record ids to link parent accounts and child contacts. 

Learn more about each of these tools and how you can use them to import data into Salesforce. 

5.2. Export data from Salesforce

 You can either manually export your Salesforce data or schedule your exports. The data will be exported as CSV files. Like data import, Salesforce offers three tools to export data: 
(a) Data export wizard 
(b) Data loader 
(c) Dataloader.io 

To learn how to export Salesforce data using these tools, read our in-depth article Admin’s Guide to Salesforce Data Export

6. Salesforce data model best practices

Having a proper data model is critical to keep your Salesforce data clean, accurate, and actionable. The following are some best practices for designing your data model in Salesforce so that you can make the most out of the data you have.

(a) Use a naming convention that is clear and consistent: Having a consistent naming convention makes it easier for users to understand the data model and for developers to work with the data model when making any changes or additions.  

(b) Create custom objects/fields only when necessary: The more custom objects/fields you create, the more complicated your data model becomes. In most cases, Salesforce will already have a standard object/field that meets your requirements.  

(c) Make the data model scalable:  If your data model is not scalable, it will eventually reach a point where it cannot accommodate any more data, as the company and its data keep growing. To make your data model scalable, identify areas where your company is likely to experience growth and design your data model in such a way that it can easily accommodate data in those areas. You also need to review your data model periodically to make sure it remains scalable and update whenever required. 

(d) Keep it simple:  A simple data model is easy to understand and maintain. It is difficult to keep track of all the relationships and fields and make changes in a complex data model. A simple data model is also easier to scale. 

(e) Set appropriate permissions for users:  When you define a data model for your Salesforce organization, you define how the data will be organized and how it can be accessed. Consider which users need access to which data in Salesforce and grant only the required permissions. 

(f) Avoid using special characters in object/field names:  When you use spaces or special characters in object or field names, it can cause problems later when you try to reference the object/field in codes. 


7. SysCloud backup for Salesforce

As discussed in the article, your organization’s Salesforce data model is important, and it impacts the user experience, data reporting, data loading, and automation. It also helps to establish relationships between specific objects. Given the complexity of relationships in Salesforce, it is important to have a Salesforce backup solution that backs up object relationships as well along with Salesforce data and metadata. 

SysCloud backup for Salesforce backs up all your Salesforce data and metadata along with object relationships. In the event of data loss or corruption, administrators can restore deleted/modified records with all object relationships intact. 

Learn how to restore Salesforce data with object relationships intact.


Get actionable SaaS administration insights

We don’t spam. Unsubscribe anytime.

In this article

  • What is Salesforce data model?
  • Salesforce objects and fields
  • Create a custom object in Salesforce
  • Create a custom field in Salesforce
  • Create a relationship between two objects
  • Salesforce Schema Builder
  • Data Management in Salesforce
  • Salesforce data model best practices

Try Salesforce backup for free!

Start 30-day Free Trial
Certifications
Certifications