The Art of Salesforce Data Modeling

Whether you’re a Salesforce novice or a seasoned user, delving into Salesforce data modeling is a game-changer. It’s not just about organizing and managing your data efficiently, but also about tailoring your Salesforce environment to your specific business needs. This blog post will equip you with the basics of Salesforce data modeling, from standard and custom objects to field and relationship data types. By the end of this article, you’ll not only grasp the fundamental concepts but also feel empowered to optimize your Salesforce experience.

The data model is a way to represent how database tables look in a way that makes sense to humans. In Salesforce, tables are objects, columns are fields, and rows are records. For example, imagine a table with the object ‘Account ‘, the fields ‘Name’ and ‘Industry ‘, and the records’ Apple’ and ‘Technology ‘. Salesforce offers several types of objects, including standard objects, custom objects, external objects, platform events, and BigObjects. However, in this discussion, we will focus on the two most common types of objects – standard and custom. Objects are containers for the information you store but also give you additional functionality. For instance, when you create a custom object, the platform automatically creates things like the page layout for the user interface.

Salesforce Objects
Different Types Of Salesforce Objects

Salesforce Standard Objects

Salesforce includes a set of pre-built, standard objects. These include commonly used business objects such as Account, Contact, Lead, and Opportunity. These pre-built standard objects can be customized and extended to meet specific business requirements.

Salesforce Custom Objects

Custom objects are a feature in Salesforce that enables you to create and store data tailored to your company’s specific business needs and requirements. They are custom database tables that can contain unique fields, relationships, and other customizations that are not available in standard objects. Custom objects allow you to manage and organize your business data more efficiently and effectively. In the API, custom object names have a suffix of two underscores followed by a lowercase “c.” A custom object record must also have a populated name field to appear in the Salesforce user interface. When creating a custom object record through the API without a name, the system will use its ID as the name.

Create a Salesforce Custom Object

Creating a custom object in Salesforce is a breeze. Navigate to the ‘Object Manager’ section in the setup menu, select the ‘Create’ option, and voila! You can specify the object name, label, and other properties in the Create Object window. It’s that simple. This straightforward process empowers you to customize your Salesforce environment confidently and easily.

Salesforce Standard Vs Custom Objects
Salesforce Standard Vs Custom Objects 1
Salesforce Standard Vs Custom Objects
Salesforce Standard Vs Custom Objects 2

Salesforce External Object

Salesforce offers a feature called External Objects, which enables users to access and interact with data stored outside the Salesforce org. These objects are similar to custom objects but rely on an external data source definition to connect with external system data. Each external object corresponds to a specific data table on the external system, and each field in the external object maps to a table column on the external system. External objects allow users and the Lightning Platform to search and interact with external data like any other data within Salesforce. Importantly, each Salesforce org can have up to 200 external objects, which does not count towards the number of custom objects in the org. External objects are helpful when you have a large amount of data that you can’t or don’t want to store in your Salesforce organization and need to use only a small amount of data at any one time. For example, a retail company might use an external object to connect to your inventory management system and display real-time product availability on your Salesforce platform.

External objects in the API are identified by a suffix of two underscores, followed immediately by a lowercase “x” character. For instance, if an external object is named “ExtraLogInfo” in the Salesforce user interface, it would be seen as ExtraLogInfo__x in that organization’s WSDL.

Salesforce Custom Object versus External Object

FeatureCustom ObjectExternal Object
Data StorageStored in the Salesforce database.Represents data stored outside Salesforce (e.g., in an external system or database).
Data AccessibilityData is accessible within Salesforce only.Data is accessible from external systems via Salesforce Connect.
Record OperationsStandard Salesforce record operations (create, read, update, delete).Limited record operations (usually read-only or read-write, depending on the external system).
CustomizationFully customizable with Salesforce declarative tools and code.Limited customization options compared to custom objects.
Data SecuritySecurity is managed within Salesforce using standard security features (profiles, roles, permission sets, etc.).Security is maintained in the external system; Salesforce respects the external system’s security settings.
ScalabilityLimited by Salesforce data storage limits.Can handle large volumes of data as it resides outside Salesforce.
PerformanceOptimized for the Salesforce platform.Dependent on the performance of the external system and network.
Real-time UpdatesUpdates are made directly in Salesforce and reflected immediately.Real-time access to external data depends on external system performance and connectivity.
Use CasesSuitable for managing data internal to Salesforce, such as business processes, workflows, and reporting.Useful for integrating with legacy systems, external databases, or cloud services while keeping data outside Salesforce.
Salesforce Custom Object versus External Object

Different types of Salesforce fields

Identity

Each record in the database is automatically assigned a unique identifier of 15 characters. This identifier is case-sensitive. You will see the identifier in the record’s URL.

System

Read-only fields display information about a record in the system that the user cannot edit. These records typically display the creator’s name, creation date, and the date when it was last modified. They provide essential information about the record’s history and can be used to track changes made over time. Since the system fields are unmodifiable, they guarantee the accuracy and reliability of this information.

For example, the ‘Created By’ field shows who created the record, the ‘Created Date’ field shows when the record was created, and the ‘Last Modified By’ field shows who last modified the record

Name

When you create records, it is essential to assign them distinct names to help you differentiate between them. You can use text-based or auto-numbered names that automatically increase in value each time you create a new record. The name field will help you keep your records organized and easily searchable whenever you need to access them in the future.

Salesforce Custom Fields

Salesforce allows you to create custom fields on standard or custom objects. These fields are known as custom fields. Every object in Salesforce comes with three standard fields: identity, system, and name. Additionally, each standard object comes with pre-built standard fields that you can customize by adding custom fields. For instance, if you’re adding a custom field to the ‘Account’ object, you might name it ‘Preferred Language ‘, give it a label like ‘Language ‘, and specify the data type as ‘Picklist’ to allow users to select from a list of languages. Custom fields can also be added to your custom objects, allowing you to tailor objects to your specific business needs. 

Salesforce Field Data Types

Salesforce Field Data Types

In Salesforce, each field has a specific data type that determines the information the field can store. There are three types of field data types in Salesforce, each with its unique characteristics and functionalities:

1. Read-Only: As the name suggests, a read-only field cannot be edited or modified. It is often used to display information generated by a formula or a Salesforce process.

2. Relationship: A relationship field establishes links between two objects in Salesforce. It enables you to create a relationship between records of different objects and access related information.

3. Generic: A generic field is a versatile field that can store various types of data, such as text, numbers, and dates. It is the most commonly used data type in Salesforce and can be customized to suit specific business needs.

Salesforce Read Only Data Types

Salesforce Read Only Data Types

Auto Number

Auto number is a feature that generates a unique sequence number for each new record in your system. You can define a display format that suits your needs. The system automatically increments and assigns the number to each new record. The auto-number field can be up to 30 characters long, with a 20-character prefix or suffix. This feature is particularly useful for fields like ‘Order Number’ or ‘Ticket Number’ that need to be unique for each record and are best managed automatically. However, it’s important to note that this feature is unavailable for external objects.

Formula

A formula field is a particular type of read-only field that allows to customize the display of data in a specific way. You can define a formula expression that determines how the field’s value is calculated based on other source fields. The formula field is automatically updated to reflect the new value whenever the source fields change. This feature is not available for external objects. Using formula fields, you can control how your data is displayed and ensure it is always up-to-date.

Roll-up summary Fields 

Roll-up summary fields are a powerful feature in Salesforce that lets you quickly calculate values from related records. For instance, you can create roll-up summary fields that automatically display a value on a master record based on the values of records in a detailed record. However, it’s important to note that these detailed records must be directly related to the master through a master-detail relationship.

One of the main benefits of roll-up summary fields is that you can perform different types of calculations with them. For instance, you can count the number of detail records related to a master record or calculate the sum, minimum, or maximum value of a field in the detail records. This functionality makes it easy to quickly see important information at a glance without manually sifting through all related records.

You can also use a few different summaries with roll-up summary fields. For example, you can use a “COUNT” summary to count the number of related records, a “SUM” summary to add up the values of a particular field, or a “MIN” or “MAX” summary to find the smallest or largest value in a specific field. This functionality gives you much flexibility regarding how you want to summarize your data.

The following are the four available options to perform calculations on roll-up summary fields:

1. Count: This option counts the total number of related records.

2. Sum: This option totals the values in the selected field. Only number, currency, and percentage fields are available for sum.

3. Min: This option displays the lowest value of the selected field for all directly related records. Only number, currency, percent, date, and DateTime fields are available for Min.

4. Max: This option displays the highest value of the selected field for all directly related records. Only number, currency, percent, date, and DateTime fields are available for Max.

Salesforce Relationship Data Types

Salesforce Relationship Data Types

Hierarchical Relationship

This feature permits users to create a hierarchical relationship between themselves and other users via a lookup field. It is intended for the user object and is used to track and organize the reporting structure within the organization. For example, a custom hierarchical relationship field could store each user’s direct manager. The resulting lookup field lists the user’s manager, simplifying the management of the reporting structure for employees.

Lookup Relationship

A lookup relationship is a feature that allows you to create an association between two records. This feature is handy when linking different types of objects in Salesforce. For example, you can look up the relationship between an opportunity and a case to associate a specific case with an opportunity.

Creating a lookup relationship generates a field that lets users select a related record by clicking a lookup icon. This icon opens a window to search for and select another record. This field can be created on standard or custom objects.

The lookup relationship field on an external object references 18-character Salesforce IDs stored in an external data source. These IDs are then matched against the parent object to establish the relationship between the two records.

Once you establish the relationship, the parent record can display a related list to show all the linked records. You can also create lookup relationship fields that link to users, standard objects, or custom objects.

By default, Salesforce clears the value of a lookup field if a record that references it is deleted. However, you can choose to prevent records from being deleted if they’re in a lookup relationship.

Lastly, it’s worth mentioning that lookup relationship fields aren’t available in Salesforce Personal Edition. Lookup relationship fields from campaign members to standard or custom objects are available, but lookup relationship fields to campaign members aren’t.

Master-Detail Relationship

A master-detail relationship creates a connection between two records in which the master record controls certain behaviors of the detail record, such as record deletion and security. This type of relationship is not available for standard or external objects. However, creating a master-detail relationship field on a custom object that links to a standard object is possible. Please note that you cannot use master-detail relationships with campaign members.

Indirect Lookup Relationship

We use an indirect lookup relationship when the external data lacks Salesforce record IDs. This relationship allows linking a child’s external object with a parent standard or custom object in Salesforce. This type of lookup relationship enables users to relate external records with Salesforce records without having to store Salesforce record IDs in the external data source.

An indirect lookup relationship links a child’s external object to a parent’s object. When creating an indirect lookup relationship field on an external object, you specify matching fields on the parent and child objects.

When creating a relationship between an object and its child object in Salesforce, you can use an external ID field on the parent object. The external ID field is a custom unique field that is selected to match against the child’s indirect lookup relationship field. The specified External Column Name determines the values of the child’s lookup relationship field. It is essential to ensure that the parent object field is case-sensitive if the external system uses case-sensitive values in the specified External Column Name. To do this, select External ID, Unique, and Treat “ABC” and “abc” as different values (case sensitive) when defining the parent object’s custom field.

External Lookup Relationship

Salesforce’s external lookup relationship field links a child object with a parent external object. Use an external lookup relationship when the parent is an external object. The child object can be a standard, custom, or external object, but the parent object must be an external object.

The standard External ID field values on the parent external object are meticulously and accurately compared to the values in the external lookup relationship field. Similarly, for a child external object, the values in the external lookup relationship field are sourced precisely from the specified External Column Name.

When mapping two external system tables that contain a lookup relationship field, the system automatically creates an external lookup relationship for the corresponding external objects.

This auto-mapping happens only if

  • The same data source syncs the parent and child objects.
  • The sync operation has already synced the parent object, or the parent and child objects are in the same sync operation.

Salesforce Generic Data Types

Checkbox

A checkbox is a graphical user interface element that allows users to indicate a record’s true (checked) or false (unchecked) attribute. When using a checkbox field to filter data in a report or list view, use “True” for checked values and “False” for unchecked values. It’s worth noting that the Data Import Wizard and the weekly report tool use “1” for checked values and “0” for unchecked values. So, it’s crucial to be mindful of the values you use to avoid any data discrepancies.

Currency

This feature enables users to input a precise amount in a particular currency. The system automatically formats the field as a currency amount, which makes it easier to read and interpret. This formatting is handy if you export data to a spreadsheet application. However, please note that this feature is not available for external objects.

Date

This feature allows users to input a specific date or select a date from a simple and intuitive popup calendar.

Date/Time 

The date and time fields in Salesforce allow users to manually enter a date and time or select it from a popup calendar. However, there are some differences in how the Date/Time fields in Lightning Experience and Salesforce Classic function. In Lightning Experience, the date and time fields are separate, allowing users to select a date and then set the time of day. The system defaults the initial time to 12:00 PM when a date is selected from the calendar. On the other hand, in Salesforce Classic, the date/time field is a single field, and users can set the current date and time by clicking on the date and time link next to the field. 

It’s worth noting that the time of day includes AM or PM notation, making it easier for users to specify the exact time. Additionally, users can limit the data by specific dates and times using any custom date field when generating reports. This feature provides greater control over the analyzed data and allows users to develop more accurate reports.

Email

The email address field can accommodate up to 80 characters and is thoroughly validated to ensure it is in the correct format. If a user fills out this field for a contact or lead, they can select that email address by clicking the “Send an Email” button when sending an email. Please note that you cannot use custom email addresses for mass emails, and the system does not log any email addresses you enter in a record’s custom email fields.

Geolocation

Geolocation is a helpful feature that lets users specify a location by its latitude and longitude. We can use this information to calculate the exact distance between two points. In your organization’s limits, this compound field consumes three custom fields: one for latitude, one for longitude, and one for internal use. It is worth noting that this feature is not currently available for external objects.

Number

This feature enables users to input any numerical value, whether it contains leading zeros or not. Leading zeros will be removed upon Salesforce saving the data. In Lightning Experience, custom objects can store decimal values up to a higher precision than what is defined in the field, which means that if you enter a value such as 90.678 in a field that accepts only two decimal places, Salesforce will display the value as 90.68 on the record form. You will see the original input value (90.678) displayed if you edit the field inline. The database will store the same value as 90.678. Salesforce Classic saves the input value of 90.678 to 90.68.

Percent

The system lets users input a percentage value in decimals, such as 0.10. Once the user enters the value, the system converts it into a percentage format, such as 10%.

Phone

Salesforce allows users to easily input any phone number with a maximum limit of 40 characters. The platform has an in-built capability to format phone numbers automatically. Additionally, if you use Salesforce CRM Call Center, custom phone fields have a Click-to-dial button that enables click-to-dial functionality. As this functionality is unavailable, Salesforce suggests avoiding using custom phone fields for fax numbers.

Picklist

You can enable users to choose a single value from your specified list. This feature is accessible for external objects exclusively through the cross-org adapter for Salesforce Connect.

Picklist (Multi-Select)

The feature lets users choose multiple picklist values from a customized list. The selected values are displayed in the field and separated by semicolons. This functionality is exclusively available for external objects and requires the cross-org adapter for Salesforce Connect.

Text

This feature empowers users to input any desired combination of characters, including letters, numbers, and symbols. Additionally, users can customize the length of their input up to a maximum of 255 characters.

Text Area

This feature allows the system to display individual lines containing 255 characters. Users can input the desired text, just like filling out a Description field.

Text Area (Long)

Users can input a large amount of text, up to 131,072 characters, and the system will display it on separate lines similar to a Description field. The length of this field type can be customized to suit your needs, with a lower limit if desired. This field type accepts any text length between 256 and 131,072 characters, with a default length of 32,768. 

Each time you press Enter while entering text in a long text area field, the system adds a line break and a return character to the text. Both of these additions count towards the 131,072-character limit. It is important to note that this data type is not available for activities or products on opportunities. 

If you show this field in a report, the report will display the first 999 characters for standard rich text area or long text area fields and only the first 255 characters for custom fields. However, you can view the entire field by downloading the report as Details Only.

Text Area (Rich)

The Rich text areas in Salesforce have some visual and formatting differences in Lightning Experience and the Salesforce mobile app compared to Salesforce Classic. Users can format the field content and add images and hyperlinks using a toolbar to perform various actions such as undo, redo, bold, italicize, underline, strikeout, align text, add lists, and upload images. The maximum field size is 131,072 characters, which includes all the formatting and HTML tags. A report displays only the first 999 characters for rich or long text areas and only the first 255 characters for custom fields. You can access the entire field by downloading the report as Details Only. The system supports only gif, jpeg, and PNG file types for uploaded images and limits their size to 1 MB. It’s important to note that rich text areas are unavailable for external objects.

Text (Encrypted)

This feature empowers users to input various characters, including letters, numbers, and symbols, which are then securely stored in encrypted form. You have the flexibility to set a maximum length of up to 175 characters, ensuring that you can accommodate complex and lengthy inputs. The encrypted fields are safeguarded with 128-bit master keys and use the Advanced Encryption Standard (AES) algorithm, ensuring your data remains private and confidential. You can also manage your master encryption key by archiving, deleting, and importing it. However, to enable master encryption key management, you must contact Salesforce. Please note that this feature is not currently available for external objects.

Time 

The system allows users to input a time of day down to the millisecond accurately. To indicate Greenwich Mean Time (GMT), a “Z” should be appended to the end of the entry. Examples of valid entries include 17:30:45.125, 17:30:45, 17:30, and 17:30:45Z. The time is displayed in a 12-hour format, indicating whether it is AM or PM. The specific time display will be determined by the Locale setting selected on the Company Information page in Setup.

URL   

The website address field in Salesforce allows users to enter up to 255 characters of any valid website URL. The record detail pages display only the first 50 characters. When a user clicks on the website address field in Salesforce Classic, the URL opens in a separate browser window. On the other hand, in Lightning Experience, internal URLs open in the same window, while external URLs open in a separate browser window. In Salesforce console apps, the URL opens in a new workspace tab. Similarly, in Lightning console apps, internal URLs open in a new workspace tab, while external URLs open in a separate browser window.

Salesforce External ID

External IDs in Salesforce are unique identifiers from a system outside of Salesforce. Enabling the ‘Unique ID’ setting ensures uniqueness for each record in Salesforce, which is a key benefit. An object can have up to 25 external ID fields, providing ample flexibility. External IDs are searchable and indexed in Salesforce, which means searching should perform quickly, enhancing efficiency. 

While you can set Email, Number, Text, and AutoNumber as External IDs, it’s important to note that in real situations, AutoNumber may not fully function as an External ID, particularly when using Data Loader for upsert operations.

Takeaways:

1. Salesforce data modeling is crucial to efficiently organizing and managing your data.

2. Salesforce offers several types of objects, including standard and custom, which can be customized to meet specific business requirements.

3. Custom objects enable the creation and storage of data according to specific business needs and requirements.

4. Each field has a specific data type that determines the information the field can store.

5. Read-only, relationship, and generic fields are the three field data types in Salesforce.

6. Auto-number and formula fields are the two read-only field data types in Salesforce.

In conclusion, Salesforce data modeling is fundamental to efficiently organizing and managing your data in Salesforce. Understanding the basics of Salesforce data modeling, including standard and custom objects, fields, and data types, can help you tailor your Salesforce environment to your business needs. By leveraging the power of custom objects and fields, you can organize and manage your unique business data more efficiently and effectively. Additionally, understanding the different field data types, including read-only, relationship, and generic fields, can help you make more informed decisions when designing your Salesforce data model. Overall, Salesforce data modeling is an essential skill for anyone looking to maximize the potential of their Salesforce environment.

Leave a Reply

Related Posts

Ameer. M.A

Full Stack Developer

I am a Full Stack web developer, Progressive Web Apps (PWA) Developer, Hybrid mobile app developer, and ERP consultant from Kerala, India.

Ameer. M.A

Explore