Data Model in Salesforce

Data Model in Salesforce

Comparte la información a tus amigos

Data Model in Salesforce can represent a collection of objects and fields in an app and how they are related to one another. That means, it can be created using Standard Objects, custom objects and relationships.

Creating a Data Model in Salesforce

  • Is a way to represent data in a database consisting of tables with columns and rows.
  • Objects represent the tables, fields represent the columns, and records represent rows in Salesforce.
  • Standard Objects can be: Account, Contact, Case and Opportunity (Sales Objects Diagram)
  • Custom Objects are used to store specific information about the company’s requirement.
  • We can set up different relationship types such as lookup and master-detail.
  • We can use Schema Builder for viewing and setting up the data model of our organization.

Choosing a Data Model in Salesforce

  • A data model is typically created for a custom application in Salesforce.
  • Business objects are provided by Salesforce, which means that custom objects are not required for them.
  • The type of relationships depends on factors such as object type, security and deletion.
  • Before create an object or field ask yourself: Does Salesforce provides us an object or field to handle this information? If not, create a custom object or field.

Types of Relationships

Lookup Relationships

  • To link two objects together loosely, that means, without depends each other.
  • Don’t have an effect on security or deletion.
  • Can be required or optional in the field definition.
  • Records of the child object can appear in a related list on the parent record.
  • A lookup relationship field can be used to link an object with itself.

Master-Detail Relationships

  • To link two objects together closely, it means that they depends each other.
  • Deleting a parent record automatically deletes the child record.
  • The child record inherit the sharing and security settings of the parent record.
  • Can be defined between two custom objects, or a standard object and a custom object, where the standard object is the parent.
  • A master-detail relationship field is always required on the detail record.
  • Child records can appear in a related list on the parent record.
  • Roll-up summary fields can be created on the parent object to summarize the child record.

Many-to-Many Relationships

  • To link each record of an object to multiple records of another object and vice versa.
  • A custom junction object is created with two master-detail relationships.
  • Access to a junction object record is determined by a user’s sharing access to both master records.
  • Junction object records are deleted when either associated master record is deleted.
  • Roll-up summary fields can be created on both master objects to summarize data from the junction object.

Impact of Modifying Objects and Fields

  • A custom object referenced in Apex or Visualforce cannot be deleted.
  • The label of an object or field can be renamed even if its referenced by Apex.
  • If a schema relationship is modified, Apex code that referes the relationship needs to be updated.

Impact of Field Modifications

  • A custom field that is referenced in Apex cannot be deleted. A new temporary field can be created and the referenced field in Apex can be replaced with the temporary field.
  • Data type of a custom field referenced by Apex or Visualforce cannot be changed.
  • Any modification to a field from Salesforce can have impact on the Apex code that references the field.
  • If new value is added to a picklist field, the logic used in Apex code may be updated.
  • Modifying the lenght or decimal place of a field may cause data loss.
  • If the value of a required field is not specified in Apex, it causes an error.
  • If a roll-up summary field is modified, it can change the output of any Apex code.

Custom Settings

  • Are similar to custom objects and can be queried like custom objects.
  • To handle static data that needs to be queried many times from the database.
  • The application cache enables efficient access to custom settings, avoiding repeated queries to the database.
  • Formula fields, validation rules, flows, Apex, and SOAP API can then use this data.
  • Can be accessed via custom setting methods or using $Setup variable.

For More Information

If you want to see more information about Salesforce, can go to Write Unit Tests for Apex in Salesforce.

Comparte la información a tus amigos


  1. Everything is very open with a precise clarification of the issues.

    It was truly informative.
    Your website is extremely helpful.
    Thanks for sharing!

    My webpage: more info