Package homePlatform Data ArchitectStudy guide
Study guide

Chapter 125% of the exam65 min

Data Modeling/Database Design

How to design a Salesforce data model that scales and respects security: objects, fields and relationship types, designing around the sharing model, capturing business and technical metadata, when to use big objects instead of standard or custom objects, and how to avoid parent-child, ownership and lookup skew.

By the end of this chapter you can

  • Compare and contrast various techniques and considerations for designing a data model for the Customer 360 Platform (for example, objects, fields & relationships, object features)
  • Given a scenario, recommend approaches and techniques to design a scalable data model that obeys the current security and sharing model
  • Compare and contrast various techniques, approaches and considerations for capturing and managing business and technical metadata (for example, business dictionary, data lineage, taxonomy, data classification)
  • Compare and contrast the different reasons for implementing big objects versus standard/custom objects within a production instance, alongside the unique pros and cons of utilizing big objects in a Salesforce data model
  • Given a customer scenario, recommend approaches and techniques to avoid data skew (record locking, sharing calculation issues, and excessive child to parent relationships)

Objects, fields and relationships

Scenario: A media company is redesigning its org for millions of subscribers. Every relationship it chooses affects security, deletion, reporting and performance.

Objects and fields

  • Object types: standard, custom (__c), external, platform events and big objects (__b).
  • Every record has an 18-character, case-insensitive ID, plus system fields such as CreatedDate and owner fields where the object has an owner.
  • Name objects and fields clearly, add descriptions and help text, and make important fields required.
  • Schema Builder shows and edits the model visually.
  • Object features such as history tracking, activities, reports, search and divisions are switched on per object.

Relationship types

Relationship types. Lookup: a loose link where the child keeps its owner and sharing, with no roll-ups. Master-detail: the detail has no owner, inherits sharing and is deleted with the master, which can hold roll-ups. Junction object: two master-detail fields make a many-to-many relationship. Hierarchical: a special lookup on the User object only. External lookup: the parent is an external object, matched by External ID. Indirect lookup: an external child links to a Salesforce parent by a unique External ID. Lookup loose link; child keeps its owner and sharing; no roll-ups Master-detail detail has no owner, inherits sharing, deleted with master; roll-ups Junction object two master-detail fields make many-to-many Hierarchical a special lookup on the User object only External lookup parent is an external object, matched by External ID Indirect lookup external child to a Salesforce parent by unique External ID
Relationship types

Type Behaviour Use when
Lookup Loose link. The child keeps its own owner and sharing. On delete, the lookup is cleared by default, or the delete can be restricted Records exist independently, such as a case and an asset
Master-detail The detail has no owner, inherits the master's sharing, is deleted with the master, and the master can hold roll-up summary fields The child has no meaning without the parent, such as invoice lines
Many-to-many A junction object with two master-detail fields Products in many bundles, and bundles with many products
Hierarchical A special lookup available only on User Management chains
Self lookup A lookup from an object to itself Account or campaign hierarchies
External lookup Links a record to a parent external object by its External ID The parent lives outside Salesforce
Indirect lookup Links a child external object to a Salesforce parent through a unique External ID field External data has no Salesforce IDs

Rules to remember

  • The master-detail field is created on the detail object, and roll-up summaries need master-detail.
  • A custom detail object can't have sharing rules, manual sharing or queues: access comes from the master.
  • A custom object can have up to 40 relationships.
  • External objects support only lookup, external lookup and indirect lookup relationships.
  • External ID fields hold keys from other systems and are indexed.

Exam tip: "Delete the children with the parent and roll up totals": master-detail. "The child needs its own owner and sharing": lookup. "Many products in many bundles": junction object.

Designing for the sharing model

Scenario: Subscribers' cases are confidential, but product data isn't. The model must give the right access without overloading sharing calculations.

Sharing and the data model. More sharing work comes from private defaults, lookups whose children have their own owners, parent implicit shares, and more than 10,000 children per parent or records per owner. Less sharing work comes from public defaults where allowed, master-detail details, Controlled by Parent, and spreading children and owners. Detail objects, and objects that are Public Read/Write for everyone, have no sharing table. More sharing work Private defaults lookups with own owners parent implicit shares 10,000+ children or records per owner Less sharing work public defaults where allowed master-detail details Controlled by Parent children spread out owners spread out No sharing table: detail objects, and objects Public Read/Write for everyone
Sharing and the data model

How access works

  • Object and field permissions decide what users can do with an object; record-level access decides which records they see, through org-wide defaults, the role hierarchy, sharing rules, teams, manual and programmatic sharing.
  • Access is granted explicitly, through group membership, by inheritance, or implicitly. Implicit sharing gives a user with access to a child, such as a case, read access to its parent account.
  • An object has no sharing table if it's the detail in a master-detail relationship, or if its internal and external defaults are both Public Read/Write.

Design choices that scale

Choice Effect
Public Read Only or Public Read/Write defaults for non-confidential data No sharing rows to calculate
Controlled by Parent for child objects Avoids parent implicit shares and their maintenance
Master-detail instead of lookup where the child always follows the parent Access is inherited, with no separate sharing table
10,000 children or fewer per parent, and 10,000 records or fewer per owner Avoids slow sharing recalculation and locks
Process hierarchy changes from the bottom up, off-peak Shorter recalculations
Deferred sharing calculations during big changes Recalculate once; deferring group membership also defers sharing rules
  • Granular locking, on by default, lets unrelated group changes run in parallel. Reparenting a role still blocks most other changes.
  • Big objects support only object and field permissions, not sharing rules.
  • Recent changes: the View All Fields permission grants access to all current and future fields on an object, and the sharing group "Roles and Subordinates" is now called "Roles and Internal Subordinates".

Exam tip: Confidential child data that always belongs to one parent: master-detail or Controlled by Parent. Public reference data: a public default, so no sharing work at all.

Managing metadata

Scenario: Nobody knows what half the fields in the org mean, who owns them or whether they hold personal data. New AI agents read the same fields and give confusing answers.

Business and technical metadata. Business metadata: the business glossary, definitions and owners, a taxonomy of terms and business lineage. Technical metadata: the data dictionary with types, sources and usage, and technical lineage scanned automatically. Classification: sensitivity level, compliance category, Data Detect findings and a business owner. Every field should have a description, help text, an owner and a sensitivity classification. Business metadata business glossary definitions and owners taxonomy of terms business lineage Technical metadata data dictionary types, sources, usage technical lineage scanned automatically Classification sensitivity level compliance category Data Detect findings business owner Every field: a description, help text, an owner and a sensitivity classification
Business and technical metadata

Metadata is data that describes data: object and field names, types, descriptions and settings, as opposed to the values in records.

Business and technical metadata

Technique Captures
Data dictionary Every object and field: type, sample values, source system, integrations, where it's used, security and history tracking. Keep it current
Business glossary Business terms, such as "Customer Transactions", linked to technical names, such as CUST_TX_001
Taxonomy A hierarchy of classifications and tags that everyone uses the same way
Data classification Labels such as PII, with each field's sensitivity level and compliance category, and its business owner
Business lineage How business data sets relate, linked by people to technical data sets
Technical lineage How data flows and is transformed between systems, discovered automatically by scanning

Practices

  • Give every new or changed field a description, help text, a business owner and, where it applies, a sensitivity classification. Blank descriptions leave AI agents and integrations with only the API name.
  • Use clear picklist values, such as "Pending legacy contract review" instead of "PND_LGCY_2".
  • Data Detect finds sensitive data in fields so classifications can be updated, and Field Audit Trail keeps a long history of field changes.

Custom metadata types or custom settings

Custom metadata types (__mdt) Custom settings
Records deploy with change sets, packages and the Metadata API Yes No: load them separately
Relationship fields Yes No
Good for Mappings, business rules and reference values, such as tax rates User, profile or org-level settings

Exam tip: "Rules and mappings that must move between environments with the code": custom metadata types. "Who owns this field and is it personal data": field classification and the data dictionary.

Big objects

Scenario: The company records 40 million usage events a month and must keep them for years, but agents only look at recent usage.

Big objects or custom objects. A big object holds billions of rows with a fixed index of 1 to 5 fields, is queried in index order, and has no triggers, flows, sharing rules or REST API. A custom object holds millions of rows, can be queried on any field and index, and has full automation, sharing, reports and encryption. A common pattern keeps recent data in a custom object and long history in a big object. Big object billions of rows fixed index, 1-5 fields query by index order no triggers or flows no sharing rules, no REST Custom object millions of rows any field, any index full automation sharing and reports encryption Pattern: recent data in a custom object, long history in a big object
Big objects or custom objects

Big objects Standard and custom objects
Scale Hundreds of millions to billions of rows, with consistent performance Millions of rows; Trailhead suggests big objects above about 20 million
Database Distributed and non-transactional Relational and transactional
Querying Only on the index: fields in order, with no gaps Any field, using indexes
Automation No triggers, flows or processes Full automation
UI and reports No standard UI; custom components; copy subsets to custom objects for reports Full UI and reports
Security Object and field permissions only; no encryption Full sharing model and encryption
APIs SOQL, Bulk API, SOAP and Chatter; no REST API All APIs

Big object rules

  • The index has 1 to 5 required fields, can't be edited or deleted after deployment, and should start with the most-used filter. Text fields in the index can total at most 100 characters.
  • SOQL must filter on index fields in order, without gaps. Only the last filter can use a range or IN; no !=, LIKE or NOT IN.
  • Writes use Database.insertImmediate(). Inserting a record with an existing index overwrites it, so inserts are idempotent, and there's no rollback.
  • Up to 100 big objects per org. Editions include them for up to 1 million records.
  • Big objects don't count against standard data storage.

When to choose them

  • Use big objects for append-heavy history: usage events, audit trails, archived records, or a customer's full interaction history.
  • Keep data that users edit, automate, share or report on in standard or custom objects. A common pattern keeps recent data in a custom object and the long tail in a big object.

Exam tip: Big objects store massive history cheaply on the platform, but they don't behave like custom objects. If the scenario needs triggers, sharing rules or standard reports on the data, the answer isn't a big object alone.

Avoiding data skew

Three kinds of skew. Parent-child skew: more than 10,000 children on one parent causes locks and slow sharing; fix it by spreading children over more parents. Ownership skew: more than 10,000 records owned by one user slows role changes; fix it by spreading owners, or giving the owner no role or a top-level role. Lookup skew: huge numbers of records point to one target and lock it on every save; fix it by spreading values or using a picklist. Long lock waits end in UNABLE_TO_LOCK_ROW. Parent-child skew 10,000+ children on one parent locks and slow sharing fix: spread children over more parents Ownership skew 10,000+ records owned by one user slow role changes fix: spread owners; no role or top role Lookup skew huge numbers of records pointing to one target locks on every save fix: spread values or use a picklist Long lock waits end in UNABLE_TO_LOCK_ROW
Three kinds of skew

Data skew happens when too many records relate to one record. It causes record locking and slow sharing recalculation.

Skew Starts when Symptoms Fixes
Parent-child A parent has more than 10,000 children Saving a child locks the parent, so parallel updates fail with UNABLE_TO_LOCK_ROW; sharing changes scan every child Spread children across a pool of parents; use Public Read/Write or Controlled by Parent where allowed
Ownership One user owns more than 10,000 records of an object Moving the owner in the role hierarchy, or in or out of groups, recalculates huge numbers of sharing rows Spread ownership; give the owner no role, or a dedicated role at the top of the hierarchy that never moves, outside sharing-rule groups
Lookup Very many records point to one lookup target Every insert or update locks the target record Spread values over more targets, leave catch-all lookups blank, use a picklist when there are few values, speed up saves

Locking basics

  • Updating a master-detail child locks the parent and the child; inserting a record that feeds a roll-up summary locks the master; a lookup locks its target.
  • A lock wait longer than about 10 seconds fails the save with UNABLE_TO_LOCK_ROW.
  • Prevent it by sequencing work by parent ID, adding retry logic, and running group changes off-peak.

Exam tip: "All unassigned contacts sit under one placeholder account": parent-child skew; spread them over several accounts. "One integration user owns millions of records": ownership skew; no role, or an isolated top role.

Hands-on exercise

Model a subscription business

Design a scalable, secure data model for a subscription company.

Use a free Salesforce Developer Edition org — never a production org.

0 of 6 steps done

How to check your work: Subscriptions are detail records of the subscriber; bundles use a junction object; usage events go to a big object with recent summaries in a custom object; the 'Direct Customers' account is split into a pool of accounts; the integration user has no role; and each field gets a description, owner and sensitivity classification.

Domain quiz: Data Modeling/Database Design

10 questions from the 50 in this domain, different each time and checked as you go. Anything you miss is saved to Mistakes review.

Questions
10
Time
Untimed
Feedback
After each answer

New questions each time you start, drawn from the bank, unseen ones first.

Master Data Management