You are on page 1of 78

Salesforce Certified Platform Developer 1

Lesson 2: Building Data Model in Salesforce and Business Processes

©Simplilearn. All rights reserved 1


What's in It for Me

Salesforce standard and custom objects

Fields and Relationship Fields

Junction Object

Formula fields, Roll-up Summary fields, and


Validation Rules

Compare Workflows and Process Builder

©Simplilearn. All rights reserved 2


Data Model
Understand the elements of Data Model in Salesforce

©Simplilearn. All rights reserved 3


Data Model

Data Model is an abstract model, diagrammatic representation of various elements of data involved in a
system. It represents how these elements are related to each other in the real world.

©Simplilearn. All rights reserved 4


Data Model—Example

Data Model is designed on paper to clearly represent the system to be created. It involves chalking out its
various elements and how they relate to each other.

User
PK ID
Name

Car

Position_c
PK ID Master-Detail Candidate_c
Job_Application_c
Name
PK ID Master-Detail PK ID
Max Salary Name
Tyres Engine Seats Min Salary Candidate_c Description
Comments Position_c

Master-Detail Master-Detail

Interviewer Review_c
PK ID PK ID
Name Job Application_c
Interview_c
Feedback_c

©Simplilearn. All rights reserved 5


Data Model in Salesforce

To create a data model for a Salesforce Application, there are building blocks such as objects, fields, and
Relationships.

DECLARATIVE PROGRAMMATIC

• Applications
• Page Layouts • Visualforce Pages
Finish Order
• Tabs • Lightning Components
• Record Types User Interface
Delivery

• Workflows • Visualforce Controllers


• Validation Rules Logic • Apex Triggers
• Process Builder • Web Services
Finish Order

• Objects Data Model • Apex Classes


• Fields • Web Services
Delivery
• Relationships • APIs

©Simplilearn. All rights reserved 6


Salesforce Objects
DATABASE

Table Table Table


Salesforce objects works as a database where you
can capture any important business information.
Table
Salesforce Objects, their fields, and relationships are
part of the Metadata that a developer needs to Table Table

create.
Table Table Table

First Name Last name Address City Age


Standard objects
Mickey Mouse 123 Fantasy Way Anaheim 73
Bat Man 321 Cavern Ave Gotham 54
Salesforce Objects
Wonder Woman 987 Truth Way Paradise 39
Donald Duck 555 Quack Street Mallard 58
Custom Objects Bugs Bunny 567 Carrot Street Rascal 58
Wiley Woman 234 Acme Way Canyon 61
Cat Woman 234 Punfect Street Hairball 32
Tweety Bird 543 Itotltaw 28

Fields
©Simplilearn. All rights reserved 7
Data Model—Keys

Primary Key is a column which uniquely identifies a row in the table, eg. CustId
A foreign key is a column in a table that uniquely identifies a row of another table.

Customer Contact
First Name Last name CustID CustID ContactInformation Contact Type
Elaine Stevens 101 101 555-2653 Work
Mary Dittman 102 101 555-0057 Cell
Skip Stevenson 103 102 555-8816 Work
Drew Lakeman 104 104 555-0949 Work
Eva Plummer 105 103 555-0650 Work

Parent Table Primary 101 555-8855 Home


Key 105 itrold@simplilearn.com Email
101 Rob@simplilearn.com Email
101 555-5787 Fax

One to Many 103 parama@simplilearn.com Email


Relationship 105 555-5657 Work
102 Dittman@simplilearn.com Email

Foreign Child Table


Key
©Simplilearn. All rights reserved 8
Salesforce Objects vs. Excel Sheet

The screenshot shows the comparison of an Excel sheet with Salesforce.

Tabs to Salesforce Objects

©Simplilearn. All rights reserved 9


Standard Objects

Standard objects are a part of the “Standard Functionality” in Salesforce.

Standard Objects

©Simplilearn. All rights reserved 10


Account Standard Object

Account is a standard object that can be used to store data about other companies you are communicating with.

©Simplilearn. All rights reserved 11


Custom Objects

The developer defines and creates custom objects if data model of the application needs to store data that
is not suitable to be stored in any of the standard objects.
Custom Objects

©Simplilearn. All rights reserved 12


Demo 1—Custom Objects
Demonstrate how to create a custom object

©Simplilearn. All rights reserved 13


Fields
Discuss standard and custom fields

©Simplilearn. All rights reserved 14


Fields

Fields are similar to columns in an Excel sheet or columns in a table of relational database.

Standard Custom

Fields

©Simplilearn. All rights reserved 15


Standard Fields

Standard fields are available Out Of The Box (OOTB) in Salesforce. As a developer, you don’t need to create
them as these fields have been provided by Salesforce as a part of the standard functionality.

©Simplilearn. All rights reserved 16


Standard Fields—ID

Salesforce ID, also known as ID or Record ID is a standard field which uniquely identifies a record in an object.

ID assigned to this record

©Simplilearn. All rights reserved 17


Standard Fields—Name

The Name field provides a short description of the record to identify it and its contents. This field is required,
but it is not unique. Consequently, two records can have the same value.

©Simplilearn. All rights reserved 18


Data Type Options of Name Field

The two data type options for the Name field are:

Text Auto-Number

©Simplilearn. All rights reserved 19


Standard Fields—Owner

The Owner field refers to a user or a group of users called Queue that will become the owner of the record.

©Simplilearn. All rights reserved 20


Standard Fields—Audits

Audits are system assigned read-only fields which are populated after record creation. These fields are called
Audit fields as they provide auditing information about the record.

1 CreatedByID

2 LastModifiedByID

3 CreatedDate

4 LastModifiedDate

©Simplilearn. All rights reserved 21


Custom Fields

Custom fields are created to store data that


cannot be relevantly stored in standard fields or
when you have run out of standard fields. Custom
fields are
Auto Number
Checkbox
Date or Date/Time
Number
Email, Phone, and URL
Picklist and Multi-Select Picklists
Text and Text Areas
Currency
Formula
Geolocation

©Simplilearn. All rights reserved 22


Custom Fields (contd.)

The screenshot shows the location of custom fields on a custom object.

©Simplilearn. All rights reserved 23


Custom Fields (contd.)

The screenshot shows the different types of custom fields created on the Position object and how they
appear on the record layout.

Text field Standard owner field


Picklist field
Date field

Checkbox field
Dependent picklist field

Currency field

Long text area field

©Simplilearn. All rights reserved 24


Demo 2—Custom Fields
Demonstrate how to create a custom field

©Simplilearn. All rights reserved 25


Relationship Fields
Understand Relationship fields and their role

©Simplilearn. All rights reserved 26


Relationship Fields

In Salesforce, Relationship fields are created between two objects that need to be associated.

These are usually defined for one-to-one or one-to-many relationships. In the relationship, one
becomes the parent and other the child object.

These fields are created on the child that refer to the parent object. The field stores the associated
parent record ID.

The two types of relationship fields available in Salesforce are Master-Detail and Lookup.

All the scenarios such as one-to-one, one-to-many, and many-to-many relationships are accomplished
using these two types of fields.

©Simplilearn. All rights reserved 27


Relationship Fields—Example

Here, there are two Objects, Position and Job Application.


Position
Position is the master and Job Application is the child object.

Position
Job
Position
Applications

Position__c Job_Application__c
Id Name Id Name Position_c

a002800000eOjww Android Developer a022800000Gf1TT JA-000001 a002800000e7RqU

a002800000eLW3 Java Developer a022800000GK3P JA-000002 a002800000e7RqU


O
a002800000e7RqU Salesforce a022800000GgqU JA-000003
Developer

©Simplilearn. All rights reserved 28


Relationship Fields—Child Record

Child records can be viewed and accessed via the layout of the parent record. The child records show as
“Related Lists”.

Position

Position
Job
Position
Applications

©Simplilearn. All rights reserved 29


Master-Detail Relationship

Master-Detail is a relationship between the parent or “master” and the child or “detail” objects.
The characteristics of Master-Detail Relationships are:
• The field created on the detail/child object becomes a required field.
• If the parent record is deleted, then all the child records will also get deleted. This is called Cascade Delete.
• The child record inherits all the permissions, such as sharing and ownership, from the parent record.

Position__c Job_Application__c
Id Name Id Name Position_c

a002800000eOjww Android Developer a022800000Gf1TT JA-000001 a002800000e7RqU

a002800000eLW3 Java Developer a022800000GK3P JA-000002 a002800000e7RqU


O
a002800000e7RqU Salesforce a022800000GgqU JA-000003
Developer

©Simplilearn. All rights reserved 30


Lookup Relationship

Lookup Relationships are used when two


objects need to be loosely coupled and the
child object needs to refer to a parent object to
establish a relevant relationship.

©Simplilearn. All rights reserved 31


Master-Detail vs. Lookup Relationship

The table outlines the major differences between Master-Detail and Lookup relationship.

Master Detail Relationship Lookup Relationship


Field is required on child record Field can be required or optional
Access to the parent determines access to Independent security and access
the child record
Cascade delete―if parent is deleted, the If the field is required, you cannot delete
child records get deleted with it the parent record
Rollup summary fields are allowed Rollup summary fields are not allowed
A standard object cannot be on the detail Lookup relationship can be created
side of the relationship between any two objects

©Simplilearn. All rights reserved 32


Demo 3—Relationship Fields
Demonstrate how to create Relationship Fields

©Simplilearn. All rights reserved 33


Knowledge Check

©Simplilearn. All rights reserved 34


KNOWLEDGE A developer needs to create a roll-up summary field on an object. Which type of relationship field
CHECK should be created and where?

a. Lookup relationship field on the child object

b. Master-detail relationship field on the parent object

c. Master-detail relationship field on the child object

d. Lookup relationship field on the parent object

©Simplilearn. All rights reserved 35


KNOWLEDGE A developer needs to create a roll-up summary field on an object. Which type of relationship field
CHECK should be created and where?

a. Lookup relationship field on the child object

b. Master-detail relationship field on the parent object

c. Master-detail relationship field on the child object

d. Lookup relationship field on the parent object

The correct answer is C

A master-detail relationship field needs to be created on the Child Object if a developer needs to create a
roll-up summary field on an object.

©Simplilearn. All rights reserved 36


Junction Object
Discuss junction object

©Simplilearn. All rights reserved 37


Many-To-Many Relationships

In a many-to many relationship two objects can be associated in a many-to-many fashion.


For example, relationship between Candidate and Position objects is many-to-many.
A candidate can apply to more than one Position, and many candidates can apply to a Position.

Many One Many

Candidate 1 Job Application Position:


for Project Manager Project Manager
Candidate 1

Candidate 1 Job Application


for Sr. Developer

Position:
Sr. Developer

Candidate 2 Candidate 2 Job Applications


for Sr. Developer

©Simplilearn. All rights reserved 38


Junction Object

To create many-to-many relationships, create a custom object called junction object. Two master-detail
relationship fields need to be created that reference the two objects to be associated. The first master-detail
relationship you create on your junction object becomes the primary relationship. This affects the following
for the junction object records:
Look and feel: The junction object's detail and edit pages use the color and any associated icon of the
primary master object.
Record ownership: The junction object records inherit the value of the Owner field from their associated
primary master record.

©Simplilearn. All rights reserved 39


Schema Builder
Understand Schema Builder and how it helps to create data model

©Simplilearn. All rights reserved 40


Schema Builder

Schema Builder is a graphical tool for viewing and modifying objects, their fields, and relationships.

©Simplilearn. All rights reserved 41


Demo 4—Schema Builder
Explore Schema Builder

©Simplilearn. All rights reserved 42


Formula Fields

Formulas are smart custom fields that are used to perform calculations relevant to the Business Case. These
fields have a rich set of functions, which are similar to Excel formulas, to perform calculations.

©Simplilearn. All rights reserved 43


Formula Fields Return Types

Formula fields have return types available. The result data type of the calculated formula should match the
return type selected for the formula field.

©Simplilearn. All rights reserved 44


Roll-up Summary Fields

Roll-up Summary Fields or RSF are read-only formula fields that calculate sum, minimum, maximum, or
record count of a field from child records.

©Simplilearn. All rights reserved 45


Demo 5—Formula and Summary Fields
Demonstrate how to create Formula and Summary Fields

©Simplilearn. All rights reserved 46


Business Logic
Creation of Business Logic in Salesforce by Declarative methods

©Simplilearn. All rights reserved 47


Business Logic in Salesforce

Multiple declarative tools, such as validation rules, workflow rules, and process builder are available to
implement business logic.

DECLARATIVE PROGRAMMATIC

• Applications
• Page Layouts • Visualforce
Finish Order
Pages
• Tabs • Lightning Components
• Record Types User Interface
Delivery

• Workflows • Visualforce Controllers


• Validation Rules Logic • Apex Triggers
• Process Builder • Web Services
Finish Order

• Objects Data Model • Apex Classes


• Fields • WebDelivery
Services
• Relationships • APIs

©Simplilearn. All rights reserved 48


Validation Rules

Validation rules help in verifying whether the data


entered in a record meets the specified criteria. It
contains a formula or expression that evaluates to
true or false. Validation rules can be used in the
following use cases:
• To enforce proper data format
• To enforce data consistency
• To prevent data loss

©Simplilearn. All rights reserved 49


Demo 6—Validation Rules
Create Validation Rules

©Simplilearn. All rights reserved 50


Workflow Rules

Workflow Rule is a declarative tool that helps in


automating processes in Salesforce. It can be created on
Yes
all custom and on almost all standard objects. Workflow Action

To create a workflow, specify the following:


• Object
• Evaluation Criteria
• Type of Action Workflow
Criteria
• Single or multiple actions satisfied?

Stop
No

©Simplilearn. All rights reserved 51


Time-Dependent Workflow Actions

Time-dependent workflow actions have time trigger defined for them. The action is queued to fire once the
workflow criteria is met.

©Simplilearn. All rights reserved 52


Demo 7—Workflow Rules
Create Workflow Rules

©Simplilearn. All rights reserved 53


Lightning Process Builder

Lightning Process Builder is a declarative process automation tool that lets you graphically design business
processes.

©Simplilearn. All rights reserved 54


Lightning Process Builder—Actions

Process Builder can perform the following actions, either immediately or scheduled later:

Actions Description

Apex Call an apex class to execute some custom logic

Create a Record Create a new record

Email Alerts Send an email alert

Flows* Trigger a flow to automate complex processes

Post to chatter Post a chatter feed to a user, a chatter group, or the record that trigger the process

Quick Actions Trigger a object specific or global quick action

Submit for Approval* Submit a record for approval

Update Records Update fields on the record that triggered the process or its related objects

©Simplilearn. All rights reserved 55


Demo 8—Lightning Process Builder
Create a Lightning Process Builder

©Simplilearn. All rights reserved 56


Quiz

©Simplilearn. All rights reserved 57


QUIZ
What action can you trigger in a Workflow but not in Process Builder?
1

a. Create Tasks

b. Send email alert

c. Update child records

d. Send outbound messages

©Simplilearn. All rights reserved 58


QUIZ
What action can you trigger in a Workflow but not in Process Builder?
1

a. Create Tasks

b. Send email alert

c. Update child records

d. Send outbound messages

The correct answer is d.

You can send outbound message in a Workflow but not in Process Builder.

©Simplilearn. All rights reserved 59


QUIZ As a Recruiting Manager, you want all Job Application records to get deleted, any time a Position

2 record is deleted. How would you make sure of this?

a. By creating a Process Builder to delete records

b. By creating a lookup relationship on Position object to Job Application and making it


required

c. By creating a Master-Detail relationship field on Job Application to Position object

d. By creating a validation rule on Job Application object

©Simplilearn. All rights reserved 60


QUIZ As a Recruiting Manager, you want all Job Application records to get deleted, any time a Position

2 record is deleted. How would you make sure of this?

a. By creating a Process Builder to delete records

b. By creating a lookup relationship on Position object to Job Application and making it


required

c. By creating a Master-Detail relationship field on Job Application to Position object

d. By creating a validation rule on Job Application object

The correct answer is c.

You ensure this by creating a Master-Detail relationship field on Job Application to Position Object.

©Simplilearn. All rights reserved 61


QUIZ
Which of the following tool lets you play around with Salesforce Data Model graphically?
3

a. Process Builder

b. Schema Builder

c. Workflow Rules

d. Salesforce Setup Menu

©Simplilearn. All rights reserved 62


QUIZ
Which of the following tool lets you play around with Salesforce Data Model graphically?
3

a. Process Builder

b. Schema Builder

c. Workflow Rules

d. Salesforce Setup Menu

The correct answer is b.

Schema Builder lets you play around with Salesforce Data Model graphically.

©Simplilearn. All rights reserved 63


QUIZ
How would you ensure that users enter only 16 digits in a credit card number field?
4

a. Validation Rules

b. Roll-up Summary Fields with Workflow Rules

c. Lightning Process Builder

d. By making the field a required field

©Simplilearn. All rights reserved 64


QUIZ
How would you ensure that users enter only 16 digits in a credit card number field?
4

a. Validation Rules

b. Roll-up Summary Fields with Workflow Rules

c. Lightning Process Builder

d. By making the field a required field

The correct answer is a.

Using validation rules, you can ensure that users enter only 16 digits in a credit card number field.

©Simplilearn. All rights reserved 65


QUIZ
Which of the following type of fields must a junction object have?
5

a. Lookup field on child to Parent object

b. Master-detail field on parent to child object

c. Master-detail field on child object to parent

d. Two lookup fields marked as required

©Simplilearn. All rights reserved 66


QUIZ
Which of the following type of fields must a junction object have?
5

a. Lookup field on child to Parent object

b. Master-detail field on parent to child object

c. Master-detail field on child object to parent

d. Two lookup fields marked as required

The correct answer is c.

A junction object must have master-detail field on child object to parent.

©Simplilearn. All rights reserved 67


Case Study
Case study to emphasize the significance of Data Model

©Simplilearn. All rights reserved 68


Case Study

Scenario Analysis Solution

As the lead developer for Universal Containers, you need to design an application for the company to help the
recruiting department to achieve their aggressive recruitment goals in 2017.
You need to design a data model and start creating the necessary elements.

©Simplilearn. All rights reserved 69


Case Study

Scenario Analysis Solution

The HR department has the following requirements:


• Positions that need to be filled should be locked.
• Candidate profiles and their details should be stored in the system.
• Job Applications that map a Candidate to one or multiple positions should be locked.
• Information about interviewers and the position for which they are interviewing.
• Their reviews need to be stored so that a suitable candidate can be hired for a position.

©Simplilearn. All rights reserved 70


Case Study

Scenario Analysis Solution

Create the following five custom objects to fulfill these requirements:


1. Position object:

Field Name Data Type

ID Standard field
Name Text, standard field
Max Salary Currency
Min Salary Currency
Comments Text

©Simplilearn. All rights reserved 71


Case Study

Scenario Analysis Solution

Create the following five custom objects to fulfill these requirements:


2. Candidate object:

Field Name Data Type

ID Standard field
Name Text, standard field
Description Text Area

©Simplilearn. All rights reserved 72


Case Study

Scenario Analysis Solution

Create the following five custom objects to fulfill these requirements:


3. Job application:

Field Name Data Type

ID Standard field
Name Auto Number (format: JA-{0000})

Standard field
Candidate__c Master-Detail to Candidate object
Position__c Master-Detail to Position object

©Simplilearn. All rights reserved 73


Case Study

Scenario Analysis Solution

Create the following five custom objects to fulfill these requirements:


4. Interviewer:

Field Name Data Type

ID Standard field
Name Text, standard field

©Simplilearn. All rights reserved 74


Case Study

Scenario Analysis Solution

Create the following five custom objects to fulfill these requirements:


5. Review:

Field Name Data Type

ID Standard field
Name Auto Number (format, RW-{00001})

Standard field
Job_Application__c Master-Detail Relationship to Job
Application object
Interviewer__c Lookup Relationship to Interview object

©Simplilearn. All rights reserved 75


Key Takeaways

©Simplilearn. All rights reserved 76


Key Takeaways

• You can create a data model using objects, fields, and relationships fields.

• You can drive business processes using fields such as formula and roll-up summary fields.
• Schema builder is a graphical tool for viewing and modifying objects, their fields, and
relationships.
• Data entered can be kept in check by creating Validation Rules.
• Workflow Rule is a declarative tool that helps in automating processes in Salesforce.
• Lightning Process Builder is a declarative process automation tool that lets you graphically design
business processes.

©Simplilearn. All rights reserved 77


This concludes “Building Data Model in Salesforce
and Business Processes.”
The next lesson is “Data Management.”

©Simplilearn. All rights reserved 78

You might also like