Data Modelling

All About Data Modelling in Salesforce

In this blog, I am going to explain the topic of data modelling, fields, and object relationships. Let’s begin with: 


It is an organized collection of information. In a relational database: 

  • Data is stored in tables. 
  • Each table comprises a number of columns of particular datatype such as text, number or date 
  • Information is stored in the rows of tables. 
  • Tables can be related to other tables using the concept of primary key and foreign key. 

Whereas in Salesforce:

  • Salesforce objects are like database tables. 
  • We use them to store persistent data. 
  • It has additional properties and features. 

dont miss out iconDon't forget to check out: How Does Salesforce Secure Your Data? Learn Here!

We have standard and custom objects: 

Standard Objects  Custom Objects 
Standard objects are out of the box  Are user-defined 
Api name doesn't end with __C  Api name ends with __C 
Limited Customization  Fully Customizable 
Eg – Accounts and Contacts  Eg – Employee__C, Customer__C 

Field Types in Salesforce 

There are primitive and custom Field types in Salesforce but here we are listing some of the custom field types as follows: 

Type 1 – Auto Number, Checkbox, Currency, Date, DateTime, Email, Number, Percent 

Type 2 – Phone, Picklist, Text, Text Area (Long/Rich), Time, URL 

Type 3 – formula, Roll-up summary, Lookup, MasterDetail, Text (Encrypted), Hierarchical, Geolocation. 

What are Object Relationships?

Object Relationships are a special field type that connects two objects together. There are two main types of object relationships: 

  • Lookup Relationship 
  • Master-detail Relationship 

Lookup Relationship – A lookup relationship essentially links two objects together so that you can “look up” one object from the related items on another object. Lookup relationships can be one-to-one or one-to-many. 

Master-Detail Relationship – In this type of relationship, one object is the master and another is the detail. The master object controls certain behaviours of the detail object, like who can view the detail’s data. 

Create a Lookup Relationship

We’re going to create two custom relationship fields. First, let’s create a lookup relationship.  

  1. From Setup, go to Object Manager | Favorite.  
  2. On the sidebar, click Fields & Relationships.  
  3. Click New. 
  4. Choose Lookup Relationship and click Next.  
  5. For Related To, choose Contact. 
  6. Click Next. 
  7. For Field Name, enter Contact, then click Next.  
  8. Click Next, Next, and Save.  

dont miss out iconCheck out another amazing blog by Bhawana here: Loop Element in Salesforce Flow | The Developer Guide

Create a Master-Detail Relationship

Now, we’re going to create a second relationship field. We want a master-detail relationship where Property is the master and Favorite is the detail. 

  1. On the Object Manager page for the custom object, click Fields & Relationships.  
  2. Click New.  
  3. Select Master-Detail Relationship and click Next.  
  4. For Related To, choose Property.  
  5. Click Next.  
  6. For Field Name, enter Property and click Next.  
  7. Click Next, Next, and Save. 

 Reference: trailhead.salesforce, apexhours


Popular Salesforce Blogs