Compártelo con 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, create it 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)
  • Use Custom Objects to store specific information about the company’s requirement.
  • We can set up different relationship types such as lookup and master-detail.
  • In addition, 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.
  • Also, 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.
  • Use lookup relationship fields 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.

Examples of Data Model in Salesforce

For More Information

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

(Visited 783 times, 1 visits today)

Compártelo con tus amigos!

Close