SlideShare a Scribd company logo
1 of 36
December 1, 2015
Lorem Ipsum Dolor
Forward-Looking Statement
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.
Go Social!
Salesforce Developers
Salesforce Developers
Salesforce Developers
The video will be posted to YouTube & the
webinar recap page (same URL as registration).This webinar is being recorded!
@salesforcedevs / #forcewebinar
▪ Don’t wait until the end to ask your question!
– Technical support will answer questions starting now.
▪ Respect Q&A etiquette
– Please don’t repeat questions. The support team is working
their way down the queue.
▪ Stick around for live Q&A at the end
– Speakers will tackle more questions at the end, time-
allowing.
▪ Head to Developer Forums
– More questions? Visit developer.salesforce.com/forums
Have Questions?
SOQL for the SQL Developer
Look for the blog post: http://bit.ly/soql4sql
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 and Fields
– Navigating the UI
▪ Knowledge of relational database concepts
– Tables
– Primary/Foreign Keys
– Joins
Agenda
▪ Data Model & Relationships
▪ Relationships & SOQL
Data Model and the Force.com Platform
▪ SObject:
– Table-like data structure
• Records
• Fields
– Extensible
– Queryable/Updatable
– Relationships
SObjects Drive Customization
Property__c
Broker__c
Desktop Mobile
Business
Process
Reporting
Security Model and Sharing
/SObjects/Property__c
APIs
Programmatic Customization
Broker__c brkr = new Broker__c();
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
– Property__c
– Broker__c
– Favorite__c
– …
▪ Custom Fields
– Status__c
– City__c
– Baths__c
– Beds__c
– Mobile_Phone__c
– …
Relationships: The Predefined Join
▪ RDBMS
– Design: Constraint
– Runtime: Query with Join
▪ Force.com
– Design: Constraint and Join
– Runtime: Relationship Query
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
Dreamhouse App
Property and Broker Relationship
developer.salesforce.com/dreamhouse
Agenda
▪ Data Model & Relationships
▪ Relationships & SOQL
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, Streaming, etc.…)
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, Status__c
FROM Property__c
WHERE Beds__c > 2
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
Broker__c
Property__c
Id
Id
Broker__c
Broker__r
Properties__r
Type: List<Property__c>
Type: Id
Type: Broker__c
1-M
Relationship Query: Child to Parent
SELECT Id, Name, Broker__c,
Broker__r.Id,
Broker__r.Region__c
FROM Property__c
WHERE Status__c = ’Available’
[
{
"Id": "a0145000000aBf4AAE",
"Name": "82 Glen Ross Lane",
"Broker__c": "a00vn000000dU3dAAE",
"Broker__r": {
"Id": "a00vn000000dU3dAAE",
"Region__c": "North"
}
},
{
"Id": "a0145000000aBf4AAE",
"Name": "Riverside Luxury Flat",
"Broker__c": "",
"Broker__r": {...}
}, ...
]
Relationship Query: Parent to Child
SELECT Id, Name, Region__c,
(SELECT Id, Name, Status__c
FROM Properties__r)
FROM Broker__c
WHERE Region__c = 'North'
[{
"Id": "a00vn000000dU3dAAE",
"Name": "Shelley Levene",
"Region__c": "North,
"Properties__r": [
{
"Id": "a0145000000aBf4AAE",
"Name": "Glengarry Manor",
"Status__c": "Available"
},
{
"Id": "a0145000000aBd4AAE",
"Name": "82 Glen Ross Lane",
"Status__c": "Closed"
}
]
}, ...]
Querying for Intersection
Select Id, Name,
Broker__r.Name,
Broker__r.Email__c
FROM Property__c
WHERE
Broker__r.Region__c = 'North'
[
{
"Id": "a0145000000aBf4AAE",
"Name": "83 Glen Ross Lane",
"Broker__r": {
"Name": "Shelley Levene",
"Email__c":"shel@machine.com"
}
},
{...},
...
]
Aggregate Queries
SELECT
City__c,
COUNT(Id) houseCount,
MAX(Price__c) maxValue,
AVG(Price__c) avgValue
FROM Property__c
GROUP BY City__c
[
{
"City__c": "Reading",
"houseCount": 81,
"maxValue": 748000,
"avgValue": 569468.50
},
{
"City__c": "Windsor",
"houseCount": 46,
"maxValue": 840000,
"avgValue": 638812.50
},
...
]
Demo
Find the total property value currently on the market
broken down by each broker region
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
Concepts to Explore Further
▪ Query Locator: database cursor abstraction
▪ Query Optimizer: translates SOQL to SQL
▪ Query Plan: examine query optimizer behavior
Read More
▪ Blog: Basic SOQL Relationship Queries: http://bit.ly/soqlrelationship
▪ SOQL-SOSL Guide http://bit.ly/soqlsosl
▪ Sharing http://bit.ly/sharingarch
▪ Limits http://bit.ly/apexgovlim
▪ Multi-Tenant Architecture http://bit.ly/sfmultiten
Q & A
Try Trailhead: trailhead.salesforce.com
Join the conversation: @salesforcedevs
Thank You

More Related Content

What's hot

Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelSalesforce Developers
 
Admin Webinar—An Admin's Guide to Profiles & Permissions
Admin Webinar—An Admin's Guide to Profiles & PermissionsAdmin Webinar—An Admin's Guide to Profiles & Permissions
Admin Webinar—An Admin's Guide to Profiles & PermissionsSalesforce Admins
 
Planning Your Migration to the Lightning Experience
Planning Your Migration to the Lightning ExperiencePlanning Your Migration to the Lightning Experience
Planning Your Migration to the Lightning ExperienceShell Black
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in SalesforceCloud Analogy
 
Advanced Uses of Salesforce's Login Flows
Advanced Uses of Salesforce's Login FlowsAdvanced Uses of Salesforce's Login Flows
Advanced Uses of Salesforce's Login FlowsSalesforce Developers
 
What is Salesforce lighting explained
What is Salesforce lighting explainedWhat is Salesforce lighting explained
What is Salesforce lighting explainedRoy Gilad
 
Dynamic input tables lwc vs aura vs. visualforce
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforceMike Tetlow
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsSalesforce Developers
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builderThinqloud
 
Generically Call External Classes from Managed Packages
Generically Call External Classes from Managed PackagesGenerically Call External Classes from Managed Packages
Generically Call External Classes from Managed PackagesSalesforce Developers
 
Salesforce Security Best Practices for Every Admin
Salesforce Security Best Practices for Every AdminSalesforce Security Best Practices for Every Admin
Salesforce Security Best Practices for Every AdminCloud Analogy
 
Episode 4 - Introduction to SOQL in Salesforce
Episode 4  - Introduction to SOQL in SalesforceEpisode 4  - Introduction to SOQL in Salesforce
Episode 4 - Introduction to SOQL in SalesforceJitendra Zaa
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsSalesforce Developers
 
Salesforce interview questions walkthrough
Salesforce interview questions walkthroughSalesforce interview questions walkthrough
Salesforce interview questions walkthroughShivam Srivastava
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforceMark Adcock
 

What's hot (20)

Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Admin Webinar—An Admin's Guide to Profiles & Permissions
Admin Webinar—An Admin's Guide to Profiles & PermissionsAdmin Webinar—An Admin's Guide to Profiles & Permissions
Admin Webinar—An Admin's Guide to Profiles & Permissions
 
Planning Your Migration to the Lightning Experience
Planning Your Migration to the Lightning ExperiencePlanning Your Migration to the Lightning Experience
Planning Your Migration to the Lightning Experience
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
 
Advanced Uses of Salesforce's Login Flows
Advanced Uses of Salesforce's Login FlowsAdvanced Uses of Salesforce's Login Flows
Advanced Uses of Salesforce's Login Flows
 
What is Salesforce lighting explained
What is Salesforce lighting explainedWhat is Salesforce lighting explained
What is Salesforce lighting explained
 
Dynamic input tables lwc vs aura vs. visualforce
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforce
 
Governor limits
Governor limitsGovernor limits
Governor limits
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard Problems
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builder
 
Apex collection patterns
Apex collection patternsApex collection patterns
Apex collection patterns
 
Generically Call External Classes from Managed Packages
Generically Call External Classes from Managed PackagesGenerically Call External Classes from Managed Packages
Generically Call External Classes from Managed Packages
 
Salesforce Security Best Practices for Every Admin
Salesforce Security Best Practices for Every AdminSalesforce Security Best Practices for Every Admin
Salesforce Security Best Practices for Every Admin
 
Exploring the Salesforce REST API
Exploring the Salesforce REST APIExploring the Salesforce REST API
Exploring the Salesforce REST API
 
Episode 4 - Introduction to SOQL in Salesforce
Episode 4  - Introduction to SOQL in SalesforceEpisode 4  - Introduction to SOQL in Salesforce
Episode 4 - Introduction to SOQL in Salesforce
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External Objects
 
Salesforce interview questions walkthrough
Salesforce interview questions walkthroughSalesforce interview questions walkthrough
Salesforce interview questions walkthrough
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
 

Similar to Modeling and Querying Data and Relationships in Salesforce

Salesforce1 Platform: Data Model, Relationships and Queries Webinar
Salesforce1 Platform: Data Model, Relationships and Queries WebinarSalesforce1 Platform: Data Model, Relationships and Queries Webinar
Salesforce1 Platform: Data Model, Relationships and Queries WebinarSalesforce Developers
 
Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2BeMyApp
 
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectSalesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectAldo Fernandez
 
Visualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsVisualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsRitesh Aswaney
 
Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Mark Adcock
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Salesforce Developers
 
Moving Sharing to a Parallel Architecture
Moving Sharing to a Parallel ArchitectureMoving Sharing to a Parallel Architecture
Moving Sharing to a Parallel ArchitectureSalesforce Developers
 
Demystify Metadata Relationships with the Dependency API
Demystify Metadata Relationships with the Dependency APIDemystify Metadata Relationships with the Dependency API
Demystify Metadata Relationships with the Dependency APIDeveloper Force
 
Pardot Story: Beyond List Email
Pardot Story: Beyond List EmailPardot Story: Beyond List Email
Pardot Story: Beyond List EmailPardot
 
The Power of Salesforce APIs World Tour Edition
The Power of Salesforce APIs World Tour EditionThe Power of Salesforce APIs World Tour Edition
The Power of Salesforce APIs World Tour EditionPeter Chittum
 
Data.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceData.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceSalesforce Developers
 
Save Millions of Clicks! Easily migrate complex schemas from SQL to Salesforce.
Save Millions of Clicks!  Easily migrate complex schemas from SQL to Salesforce.Save Millions of Clicks!  Easily migrate complex schemas from SQL to Salesforce.
Save Millions of Clicks! Easily migrate complex schemas from SQL to Salesforce.Daniel Peter
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentSalesforce Developers
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectSalesforce Developers
 
Cutting Edge Mobile Development in the App Cloud
Cutting Edge Mobile Development in the App CloudCutting Edge Mobile Development in the App Cloud
Cutting Edge Mobile Development in the App CloudSalesforce Developers
 
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...Known and unknown Salesforce Marketing Cloud limitations… and some workaround...
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...CzechDreamin
 
Force.com Integration Using Web Services With .NET & PHP Apps
Force.com Integration Using Web Services With .NET & PHP AppsForce.com Integration Using Web Services With .NET & PHP Apps
Force.com Integration Using Web Services With .NET & PHP AppsSalesforce Developers
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersSalesforce Developers
 
Developing on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeDeveloping on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeSalesforce Developers
 

Similar to Modeling and Querying Data and Relationships in Salesforce (20)

Salesforce1 Platform: Data Model, Relationships and Queries Webinar
Salesforce1 Platform: Data Model, Relationships and Queries WebinarSalesforce1 Platform: Data Model, Relationships and Queries Webinar
Salesforce1 Platform: Data Model, Relationships and Queries Webinar
 
Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2
 
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectSalesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
 
Visualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsVisualforce Hack for Junction Objects
Visualforce Hack for Junction Objects
 
Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17
 
Moving Sharing to a Parallel Architecture
Moving Sharing to a Parallel ArchitectureMoving Sharing to a Parallel Architecture
Moving Sharing to a Parallel Architecture
 
Demystify Metadata Relationships with the Dependency API
Demystify Metadata Relationships with the Dependency APIDemystify Metadata Relationships with the Dependency API
Demystify Metadata Relationships with the Dependency API
 
Pardot Story: Beyond List Email
Pardot Story: Beyond List EmailPardot Story: Beyond List Email
Pardot Story: Beyond List Email
 
The Power of Salesforce APIs World Tour Edition
The Power of Salesforce APIs World Tour EditionThe Power of Salesforce APIs World Tour Edition
The Power of Salesforce APIs World Tour Edition
 
Data.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceData.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in Salesforce
 
Introduction to Force.com
Introduction to Force.comIntroduction to Force.com
Introduction to Force.com
 
Save Millions of Clicks! Easily migrate complex schemas from SQL to Salesforce.
Save Millions of Clicks!  Easily migrate complex schemas from SQL to Salesforce.Save Millions of Clicks!  Easily migrate complex schemas from SQL to Salesforce.
Save Millions of Clicks! Easily migrate complex schemas from SQL to Salesforce.
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning Connect
 
Cutting Edge Mobile Development in the App Cloud
Cutting Edge Mobile Development in the App CloudCutting Edge Mobile Development in the App Cloud
Cutting Edge Mobile Development in the App Cloud
 
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...Known and unknown Salesforce Marketing Cloud limitations… and some workaround...
Known and unknown Salesforce Marketing Cloud limitations… and some workaround...
 
Force.com Integration Using Web Services With .NET & PHP Apps
Force.com Integration Using Web Services With .NET & PHP AppsForce.com Integration Using Web Services With .NET & PHP Apps
Force.com Integration Using Web Services With .NET & PHP Apps
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events Handlers
 
Developing on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not CodeDeveloping on the Salesforce Platform With Clicks, Not Code
Developing on the Salesforce Platform With Clicks, Not Code
 

More from Salesforce Developers

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSalesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceSalesforce Developers
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base ComponentsSalesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsSalesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaSalesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsSalesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsSalesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsSalesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and TestingSalesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPSalesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceSalesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureSalesforce Developers
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DXSalesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectSalesforce Developers
 

More from Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 
Introduction to MuleSoft
Introduction to MuleSoftIntroduction to MuleSoft
Introduction to MuleSoft
 

Recently uploaded

XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 

Recently uploaded (20)

XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 

Modeling and Querying Data and Relationships in Salesforce

  • 2. Forward-Looking Statement 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.
  • 3. Go Social! Salesforce Developers Salesforce Developers Salesforce Developers The video will be posted to YouTube & the webinar recap page (same URL as registration).This webinar is being recorded! @salesforcedevs / #forcewebinar
  • 4. ▪ Don’t wait until the end to ask your question! – Technical support will answer questions starting now. ▪ Respect Q&A etiquette – Please don’t repeat questions. The support team is working their way down the queue. ▪ Stick around for live Q&A at the end – Speakers will tackle more questions at the end, time- allowing. ▪ Head to Developer Forums – More questions? Visit developer.salesforce.com/forums Have Questions?
  • 5. SOQL for the SQL Developer Look for the blog post: http://bit.ly/soql4sql
  • 6. Agenda ▪ Data Model & Relationships – Comparing Force.com with Relational DBMS – Relationship Types & the Predefined Join ▪ Relationships & SOQL – SOQL vs SQL – Relationship Queries
  • 7. Assumptions ▪ A basic understanding of the Force.com Platform including: – Creating Custom Objects and Fields – Navigating the UI ▪ Knowledge of relational database concepts – Tables – Primary/Foreign Keys – Joins
  • 8. Agenda ▪ Data Model & Relationships ▪ Relationships & SOQL
  • 9. Data Model and the Force.com Platform ▪ SObject: – Table-like data structure • Records • Fields – Extensible – Queryable/Updatable – Relationships
  • 10. SObjects Drive Customization Property__c Broker__c Desktop Mobile Business Process Reporting Security Model and Sharing /SObjects/Property__c APIs Programmatic Customization Broker__c brkr = new Broker__c();
  • 11. Standard Data Model ▪ Standard Objects – Account – Contact – Lead – Opportunity – Case – … ▪ Standard Fields – Id – Name – CreatedBy/Date – LastModifiedBy/Date – OwnerId – IsDeleted – …
  • 12. Extensible Data Model ▪ Custom Objects – Property__c – Broker__c – Favorite__c – … ▪ Custom Fields – Status__c – City__c – Baths__c – Beds__c – Mobile_Phone__c – …
  • 13. Relationships: The Predefined Join ▪ RDBMS – Design: Constraint – Runtime: Query with Join ▪ Force.com – Design: Constraint and Join – Runtime: Relationship Query
  • 14. 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
  • 15. Demo Dreamhouse App Property and Broker Relationship developer.salesforce.com/dreamhouse
  • 16. Agenda ▪ Data Model & Relationships ▪ Relationships & SOQL
  • 17. 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, Streaming, etc.…)
  • 18. From SQL to SOQL ▪ At first may look familiar ▪ Important differences ▪ Learn the differences ▪ Use good data design practices
  • 19. From SQL to SOQL: The Familiar Bits ▪ Table-like structure ▪ Similar query syntax ▪ Indexed ▪ Transactional ▪ Triggers SELECT Id, Name, Status__c FROM Property__c WHERE Beds__c > 2
  • 20. From SQL to SOQL: Immediate Differences ▪ No select * ▪ No views ▪ SOQL is read-only ▪ Limited indexes ▪ Object-relational mapping is automatic ▪ Schema changes protected
  • 21. 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
  • 22. The __c and __r Suffixes Broker__c Property__c Id Id Broker__c Broker__r Properties__r Type: List<Property__c> Type: Id Type: Broker__c 1-M
  • 23. Relationship Query: Child to Parent SELECT Id, Name, Broker__c, Broker__r.Id, Broker__r.Region__c FROM Property__c WHERE Status__c = ’Available’ [ { "Id": "a0145000000aBf4AAE", "Name": "82 Glen Ross Lane", "Broker__c": "a00vn000000dU3dAAE", "Broker__r": { "Id": "a00vn000000dU3dAAE", "Region__c": "North" } }, { "Id": "a0145000000aBf4AAE", "Name": "Riverside Luxury Flat", "Broker__c": "", "Broker__r": {...} }, ... ]
  • 24. Relationship Query: Parent to Child SELECT Id, Name, Region__c, (SELECT Id, Name, Status__c FROM Properties__r) FROM Broker__c WHERE Region__c = 'North' [{ "Id": "a00vn000000dU3dAAE", "Name": "Shelley Levene", "Region__c": "North, "Properties__r": [ { "Id": "a0145000000aBf4AAE", "Name": "Glengarry Manor", "Status__c": "Available" }, { "Id": "a0145000000aBd4AAE", "Name": "82 Glen Ross Lane", "Status__c": "Closed" } ] }, ...]
  • 25. Querying for Intersection Select Id, Name, Broker__r.Name, Broker__r.Email__c FROM Property__c WHERE Broker__r.Region__c = 'North' [ { "Id": "a0145000000aBf4AAE", "Name": "83 Glen Ross Lane", "Broker__r": { "Name": "Shelley Levene", "Email__c":"shel@machine.com" } }, {...}, ... ]
  • 26. Aggregate Queries SELECT City__c, COUNT(Id) houseCount, MAX(Price__c) maxValue, AVG(Price__c) avgValue FROM Property__c GROUP BY City__c [ { "City__c": "Reading", "houseCount": 81, "maxValue": 748000, "avgValue": 569468.50 }, { "City__c": "Windsor", "houseCount": 46, "maxValue": 840000, "avgValue": 638812.50 }, ... ]
  • 27. Demo Find the total property value currently on the market broken down by each broker region
  • 28. 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
  • 29. Concepts to Explore Further ▪ Query Locator: database cursor abstraction ▪ Query Optimizer: translates SOQL to SQL ▪ Query Plan: examine query optimizer behavior
  • 30. Read More ▪ Blog: Basic SOQL Relationship Queries: http://bit.ly/soqlrelationship ▪ SOQL-SOSL Guide http://bit.ly/soqlsosl ▪ Sharing http://bit.ly/sharingarch ▪ Limits http://bit.ly/apexgovlim ▪ Multi-Tenant Architecture http://bit.ly/sfmultiten
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Q & A Try Trailhead: trailhead.salesforce.com Join the conversation: @salesforcedevs