SlideShare a Scribd company logo
Webinar: Data Models,
Relationships and SOQL
April 8, 2014
Rob Woodward
Platform Solution Engineer
@robw116
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or
implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking,
including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements
regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded
services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality
for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results
and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated
with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history,
our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer
deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further
information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for
the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing
important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available
and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions
based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-
looking statements.
Agenda
Data Model & Relationships
Comparing Force.com with Relational DBMS
Relationship Types & the Predefined Join
Relationships & SOQL
SOQL vs SQL
Relationship Queries
Assumptions
 A basic understanding of the Force.com Platform
including:
– Creating Custom Objects
– Adding Custom Fields
– Navigating the UI
 Knowledge of relational database concepts
– Tables
– Primary/Foreign Keys
– Joins
Data Model and Relationships
Relationships and SOQL
Agenda
Data Model and the Force.com Platform
 sObject:
– Table-like data structure
• Records
• Fields
– Extensible
– Queryable/Updatable
– Relationships
 Automatic Features:
– User Interface
– Security
• CRUD
• Field-level
• Record-level (ACL)
– REST & SOAP APIs
Standard Data Model
 Standard Objects
– Account
– Contact
– Lead
– Opportunity
– Case
– …
 Standard Fields
– Id
– Name
– CreatedBy/Date
– LastModifiedBy/Date
– OwnerId
– IsDeleted
– …
Extensible Data Model
 Custom Objects
– Workshop__c
– Room__c
– …
 Custom Fields
– Status__c
– Type__c
– Start_Time__c
– End_Time__c
– …
Relationships: The Predefined Join
 RDBMS
– Join at runtime
with SQL or
view
 Force.com
– Predefined join
at design-time
– Similar to
integrity
constraints
Master-DetailLookup
Relationship Types
NeverOptional
Cascade
Clear
Field/Block/Cascade*
Nullability
Delete Behavior
Child Inherits from ParentIndependent Parent/Child
225
Record Sharing
Access
Max Allowed Fields
Demo Use Case:
– Community Centre
– Workshops and Rooms
Data Model and Relationships
Relationships and SOQL
Agenda
SOQL
 Salesforce Object Query Language
 SQL-like syntax
 Queries the Force.com Object Layer
 Used in:
– Apex
– Developer Tools (Developer Console, Eclipse, Workbench, …)
– API (REST, SOAP, Bulk, …)
From SQL to SOQL
 At first may look familiar
 Important differences
 Learn the differences
 Use good data design practices
From SQL to SOQL: The Familiar Bits
 Table-like structure
 Similar query syntax
 Indexed
 Transactional
 Triggers
SELECT Id, Name, Capacity__c
FROM Room__c
WHERE Capacity__c > 10
From SQL to SOQL: Immediate Differences
 No select *
 No views
 SOQL is read-only
 Limited indexes
 Object-relational mapping is automatic
 Schema changes protected
From SQL to SOQL: Differences To Learn
 sObjects are not actually tables – multi-tenant
environment
 Relationship metadata
– Management of referential integrity
– Predefines joins
– Relationship query syntax
 Query usage explicitly metered
– API Batch Limits
– Apex Governor Limits
The __c and __r Suffixes
Room__c
Workshop__c
Id
Id
Room__c
Room__r
Workshops__r Type:
List<Workshop__c>
Type: Id
Type: Room__c
1-M
Relationship Query: Child to Parent
SELECT Id, Name, Room__c,
Room__r.Id,
Room__r.Capacity__c
FROM Workshop__c
WHERE Status__c = ’Open’
[
{
"Id": "a0145000000aBf4AAE",
"Name": "Yoga for Beginners",
"Room__c": "a00vn000000dU3dAAE",
"Room__r": {
"Id": "a00vn000000dU3dAAE",
"Capacity__c": 10
}
},
{
"Id": "a0145000000aBf4AAE",
"Name": "Yoga for Beginners",
"Room__c": "",
"Room__r": ""
}, ...
]
Relationship Query: Parent to Child
SELECT Id, Name,
(SELECT Id, Status__c
FROM Workshops__r)
FROM Room__c
WHERE Capacity__c > 10
[
{
"Id": "a00vn000000dU3dAAE",
"Name": "Salon 1 West",
"Workshops__r": [
{
"Id": "a0145000000aBf4AAE",
"Status__c": "Open"
},
{
"Id": "a0145000000aBd4AAE",
"Status__c": "Full"
}
]
}, ...
]
Querying for Intersection
Select Id, Name,
Room__r.Name,
Room__r.Capacity__c
FROM Workshop__c
WHERE
Room__r.Capacity__c > 8
[
{
"Id": "a0145000000aBf4AAE",
"Name": "Yoga for Beginners",
"Room__c": "a00vn000000dU3dAAE",
"Room__r": {
"Id": "a00vn000000dU3dAAE",
"Capacity__c": 10
}
},
{...},
...
]
Aggregate Queries
SELECT
COUNT(Id) rmCount,
MAX(Capacity__c) maxRmCap,
Configuration__c
FROM Room__c
GROUP BY Configuration__c
[
{
"rmCount": 4,
"maxRmCap": 6,
"Configuration__c": "Classroom"
},
{
"rmCount": 2,
"maxRmCap": 10,
"Configuration__c": "Theatre"
},
...
]
Demo Use Case:
– Find a tally of empty spaces
being held for workshops that
are not actively enrolling
delegates
Recap
 Data Model &
Relationships
– Much that looks similar,
but
– Many important
differences
– Predefined Join
– Relationship Types
 Relationships & SOQL
– SOQL has relations but is
not “relational”
– Limits cannot be ignored
– Good design principles
still apply but check your
assumptions
Read More
 Article: From SQL to SOQL http://bit.ly/sql2soql
 SOQL-SOSL Guide http://bit.ly/soqlsosl
 Sharing http://bit.ly/sharingarch
 Limits http://bit.ly/apexgovlim
 Multi-Tenant Architecture http://bit.ly/sfmultiten
Next Webinar:
May 15: Intro to building Mobile Apps with
Salesforce1 Platform – No code required

More Related Content

PPTX
Salesforce data model
DOCX
Shivam Agarwal
PPTX
SFDC Data Models For Pros - Simplifying The Complexities
PPTX
Ela Conf 2016 Opening Keynote
PPTX
Data model in salesforce
PDF
Mbf2 salesforce webinar 2
PPTX
Modeling and Querying Data and Relationships in Salesforce
PPTX
All Aboard the Boxcar! Going Beyond the Basics of REST
Salesforce data model
Shivam Agarwal
SFDC Data Models For Pros - Simplifying The Complexities
Ela Conf 2016 Opening Keynote
Data model in salesforce
Mbf2 salesforce webinar 2
Modeling and Querying Data and Relationships in Salesforce
All Aboard the Boxcar! Going Beyond the Basics of REST

Similar to Salesforce1 Platform: Data Model, Relationships and Queries Webinar (20)

PDF
Understanding the Salesforce Architecture: How We Do the Magic We Do
PPTX
OData: A Standard API for Data Access
PPTX
Integrating with salesforce
PDF
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
PDF
Exploring SQL Server Azure Database Relationships Using Lightning Connect
PDF
Designing Custom REST and SOAP Interfaces on Force.com
PDF
Beyond Custom Metadata Types
PDF
Design Patterns Every ISV Needs to Know (October 15, 2014)
PDF
Get ready for your platform developer i certification webinar
PPT
Designing custom REST and SOAP interfaces on Force.com
PPT
Next Generation Web Services
PPTX
Solving Complex Data Load Challenges
PDF
Moving Sharing to a Parallel Architecture
PPTX
Understanding Multitenancy and the Architecture of the Salesforce Platform
PPTX
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
PDF
Building towards a Composite API Framework in Salesforce
PPTX
Exploring the Salesforce REST API
PPTX
The Power of Salesforce APIs World Tour Edition
PPTX
New Powerful API Enhancements for Summer '15
PPT
Intro to AppExchange - Building Composite Apps
Understanding the Salesforce Architecture: How We Do the Magic We Do
OData: A Standard API for Data Access
Integrating with salesforce
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Designing Custom REST and SOAP Interfaces on Force.com
Beyond Custom Metadata Types
Design Patterns Every ISV Needs to Know (October 15, 2014)
Get ready for your platform developer i certification webinar
Designing custom REST and SOAP interfaces on Force.com
Next Generation Web Services
Solving Complex Data Load Challenges
Moving Sharing to a Parallel Architecture
Understanding Multitenancy and the Architecture of the Salesforce Platform
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Building towards a Composite API Framework in Salesforce
Exploring the Salesforce REST API
The Power of Salesforce APIs World Tour Edition
New Powerful API Enhancements for Summer '15
Intro to AppExchange - Building Composite Apps
Ad

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
PDF
Local development with Open Source Base Components
PPTX
TrailheaDX India : Developer Highlights
PDF
Why developers shouldn’t miss TrailheaDX India
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
PPTX
Enterprise-grade UI with open source Lightning Web Components
PPTX
TrailheaDX and Summer '19: Developer Highlights
PDF
Live coding with LWC
PDF
Lightning web components - Episode 4 : Security and Testing
PDF
LWC Episode 3- Component Communication and Aura Interoperability
PDF
Lightning web components episode 2- work with salesforce data
PDF
Lightning web components - Episode 1 - An Introduction
PDF
Migrating CPQ to Advanced Calculator and JSQCP
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
PDF
Modern Development with Salesforce DX
PDF
Get Into Lightning Flow Development
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Local development with Open Source Base Components
TrailheaDX India : Developer Highlights
Why developers shouldn’t miss TrailheaDX India
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Converting Aura Components to Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
TrailheaDX and Summer '19: Developer Highlights
Live coding with LWC
Lightning web components - Episode 4 : Security and Testing
LWC Episode 3- Component Communication and Aura Interoperability
Lightning web components episode 2- work with salesforce data
Lightning web components - Episode 1 - An Introduction
Migrating CPQ to Advanced Calculator and JSQCP
Scale with Large Data Volumes and Big Objects in Salesforce
Replicate Salesforce Data in Real Time with Change Data Capture
Modern Development with Salesforce DX
Get Into Lightning Flow Development
Integrate CMS Content Into Lightning Communities with CMS Connect
Ad

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Spectroscopy.pptx food analysis technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
Per capita expenditure prediction using model stacking based on satellite ima...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectroscopy.pptx food analysis technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
cuic standard and advanced reporting.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
Empathic Computing: Creating Shared Understanding

Salesforce1 Platform: Data Model, Relationships and Queries Webinar

  • 1. Webinar: Data Models, Relationships and SOQL April 8, 2014
  • 2. Rob Woodward Platform Solution Engineer @robw116
  • 3. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements.
  • 4. Agenda Data Model & Relationships Comparing Force.com with Relational DBMS Relationship Types & the Predefined Join Relationships & SOQL SOQL vs SQL Relationship Queries
  • 5. Assumptions  A basic understanding of the Force.com Platform including: – Creating Custom Objects – Adding Custom Fields – Navigating the UI  Knowledge of relational database concepts – Tables – Primary/Foreign Keys – Joins
  • 6. Data Model and Relationships Relationships and SOQL Agenda
  • 7. Data Model and the Force.com Platform  sObject: – Table-like data structure • Records • Fields – Extensible – Queryable/Updatable – Relationships  Automatic Features: – User Interface – Security • CRUD • Field-level • Record-level (ACL) – REST & SOAP APIs
  • 8. Standard Data Model  Standard Objects – Account – Contact – Lead – Opportunity – Case – …  Standard Fields – Id – Name – CreatedBy/Date – LastModifiedBy/Date – OwnerId – IsDeleted – …
  • 9. Extensible Data Model  Custom Objects – Workshop__c – Room__c – …  Custom Fields – Status__c – Type__c – Start_Time__c – End_Time__c – …
  • 10. Relationships: The Predefined Join  RDBMS – Join at runtime with SQL or view  Force.com – Predefined join at design-time – Similar to integrity constraints
  • 11. Master-DetailLookup Relationship Types NeverOptional Cascade Clear Field/Block/Cascade* Nullability Delete Behavior Child Inherits from ParentIndependent Parent/Child 225 Record Sharing Access Max Allowed Fields
  • 12. Demo Use Case: – Community Centre – Workshops and Rooms
  • 13. Data Model and Relationships Relationships and SOQL Agenda
  • 14. SOQL  Salesforce Object Query Language  SQL-like syntax  Queries the Force.com Object Layer  Used in: – Apex – Developer Tools (Developer Console, Eclipse, Workbench, …) – API (REST, SOAP, Bulk, …)
  • 15. From SQL to SOQL  At first may look familiar  Important differences  Learn the differences  Use good data design practices
  • 16. From SQL to SOQL: The Familiar Bits  Table-like structure  Similar query syntax  Indexed  Transactional  Triggers SELECT Id, Name, Capacity__c FROM Room__c WHERE Capacity__c > 10
  • 17. From SQL to SOQL: Immediate Differences  No select *  No views  SOQL is read-only  Limited indexes  Object-relational mapping is automatic  Schema changes protected
  • 18. From SQL to SOQL: Differences To Learn  sObjects are not actually tables – multi-tenant environment  Relationship metadata – Management of referential integrity – Predefines joins – Relationship query syntax  Query usage explicitly metered – API Batch Limits – Apex Governor Limits
  • 19. The __c and __r Suffixes Room__c Workshop__c Id Id Room__c Room__r Workshops__r Type: List<Workshop__c> Type: Id Type: Room__c 1-M
  • 20. Relationship Query: Child to Parent SELECT Id, Name, Room__c, Room__r.Id, Room__r.Capacity__c FROM Workshop__c WHERE Status__c = ’Open’ [ { "Id": "a0145000000aBf4AAE", "Name": "Yoga for Beginners", "Room__c": "a00vn000000dU3dAAE", "Room__r": { "Id": "a00vn000000dU3dAAE", "Capacity__c": 10 } }, { "Id": "a0145000000aBf4AAE", "Name": "Yoga for Beginners", "Room__c": "", "Room__r": "" }, ... ]
  • 21. Relationship Query: Parent to Child SELECT Id, Name, (SELECT Id, Status__c FROM Workshops__r) FROM Room__c WHERE Capacity__c > 10 [ { "Id": "a00vn000000dU3dAAE", "Name": "Salon 1 West", "Workshops__r": [ { "Id": "a0145000000aBf4AAE", "Status__c": "Open" }, { "Id": "a0145000000aBd4AAE", "Status__c": "Full" } ] }, ... ]
  • 22. Querying for Intersection Select Id, Name, Room__r.Name, Room__r.Capacity__c FROM Workshop__c WHERE Room__r.Capacity__c > 8 [ { "Id": "a0145000000aBf4AAE", "Name": "Yoga for Beginners", "Room__c": "a00vn000000dU3dAAE", "Room__r": { "Id": "a00vn000000dU3dAAE", "Capacity__c": 10 } }, {...}, ... ]
  • 23. Aggregate Queries SELECT COUNT(Id) rmCount, MAX(Capacity__c) maxRmCap, Configuration__c FROM Room__c GROUP BY Configuration__c [ { "rmCount": 4, "maxRmCap": 6, "Configuration__c": "Classroom" }, { "rmCount": 2, "maxRmCap": 10, "Configuration__c": "Theatre" }, ... ]
  • 24. Demo Use Case: – Find a tally of empty spaces being held for workshops that are not actively enrolling delegates
  • 25. Recap  Data Model & Relationships – Much that looks similar, but – Many important differences – Predefined Join – Relationship Types  Relationships & SOQL – SOQL has relations but is not “relational” – Limits cannot be ignored – Good design principles still apply but check your assumptions
  • 26. Read More  Article: From SQL to SOQL http://bit.ly/sql2soql  SOQL-SOSL Guide http://bit.ly/soqlsosl  Sharing http://bit.ly/sharingarch  Limits http://bit.ly/apexgovlim  Multi-Tenant Architecture http://bit.ly/sfmultiten
  • 27. Next Webinar: May 15: Intro to building Mobile Apps with Salesforce1 Platform – No code required