Data Modeling
Data modeling on the Salesforce platform differs from traditional relational database design in fundamental ways. The platform imposes governor limits, sharing model constraints, and relationship rules that shape every design decision. Every modeling choice cascades into security, integration, and performance.
Standard vs Custom Objects
Section titled “Standard vs Custom Objects”The first decision in any data model: use what Salesforce provides, or build your own.
When to Use Standard Objects
Section titled “When to Use Standard Objects”Standard objects (Account, Contact, Opportunity, Case, Lead) come with built-in features that are expensive to replicate:
- Pre-built relationships: Account-Contact, Account-Opportunity hierarchies
- Platform features: Lead conversion, Opportunity forecasting, Case escalation, Email-to-Case
- AppExchange compatibility: Most packages expect standard objects
- Standard reports and dashboards: Out-of-the-box analytics
- Mobile and Lightning optimizations: Standard objects have dedicated page layouts and Lightning components
- Process automation: Pre-built approval processes, assignment rules, escalation rules
When to Use Custom Objects
Section titled “When to Use Custom Objects”Custom objects make sense when:
- No standard object fits the business concept (e.g., Project, Inventory Item, Policy)
- Full control over field-level security is needed without fighting inherited permissions
- The entity has no overlap with standard object behavior
- A standard object would be polluted with unrelated fields (e.g., cramming warehouse data into Account)
The Decision Framework
Section titled “The Decision Framework”| Factor | Standard Object | Custom Object |
|---|---|---|
| Built-in features | Yes - lead conversion, forecasting, etc. | Must be built manually |
| AppExchange integration | Smooth | May require mapping |
| Governor limits | Slightly higher in some cases | Standard limits apply |
| Customization freedom | Limited by existing fields/behavior | Full control |
| Sharing model | May inherit complex defaults | Clean slate |
| Reporting | Pre-built reports available | Custom report types needed |
Relationships Deep Dive
Section titled “Relationships Deep Dive”Relationships in Salesforce are not just foreign keys. They drive sharing, roll-ups, deletion behavior, and query structure. Choosing the wrong relationship type is one of the most costly data modeling mistakes.
Lookup vs Master-Detail
Section titled “Lookup vs Master-Detail”Master-Detail Characteristics
Section titled “Master-Detail Characteristics”| Behavior | Detail |
|---|---|
| Cascade delete | Deleting the master deletes all detail records |
| Sharing inheritance | Detail inherits sharing from master; no independent sharing rules |
| Roll-up summaries | COUNT, SUM, MIN, MAX on detail records |
| Owner field | Detail record has no OwnerId; ownership follows master |
| Required field | Master-detail field is always required |
| Reparenting | Off by default; can be enabled but rarely recommended |
| Limit | 2 master-detail relationships per object |
Lookup Characteristics
Section titled “Lookup Characteristics”| Behavior | Detail |
|---|---|
| Cascade delete | No cascade; child record becomes orphaned (lookup field set to null) |
| Sharing | Independent sharing model; child has its own OwnerId |
| Roll-up summaries | Not natively supported (use triggers, DLRS, or Flow) |
| Required field | Optional by default; can be made required |
| Reparenting | Always allowed |
| Limit | 40 total relationships per object (combining lookups and master-detail; the 2 MD relationships count toward the 40 total) |
Hierarchical Relationships
Section titled “Hierarchical Relationships”Only available on User object. Used for approval processes, role hierarchy, and manager chains. Relevant for CTA scenarios involving approval routing or reporting structures.
External Lookups
Section titled “External Lookups”Link standard/custom objects to External Objects. The relationship is based on an External ID rather than a Salesforce record ID. Critical for Salesforce Connect architectures.
Junction Objects for Many-to-Many
Section titled “Junction Objects for Many-to-Many”When two objects have a many-to-many relationship, a junction object with two master-detail relationships is required.
Junction Object Rules
Section titled “Junction Object Rules”- The junction object has two master-detail relationships, each pointing to one side of the M:N
- The first master-detail (created first) determines the primary relationship and sharing model
- The junction object can have its own fields (enrollment date, status, grade)
- Deleting either master deletes the junction record
- Related lists appear on both parent objects
Polymorphic Lookups
Section titled “Polymorphic Lookups”Polymorphic lookups point to multiple object types. Salesforce has built-in polymorphic fields:
| Field | Object | Points To |
|---|---|---|
WhoId | Task, Event | Contact OR Lead |
WhatId | Task, Event | Account, Opportunity, Case, Custom Objects, etc. |
OwnerId | Most objects | User OR Queue |
RelatedToId | EmailMessage | Multiple objects |
CTA Implications
Section titled “CTA Implications”- SOQL complexity: You must use
TYPEOFin SOQL to handle polymorphic fields:SELECT Id, Subject,TYPEOF WhoWHEN Contact THEN FirstName, LastName, Account.NameWHEN Lead THEN FirstName, LastName, CompanyENDFROM Task - Reporting limitations: Polymorphic fields create complex report type requirements
- Trigger design: Apex triggers must handle multiple object types in the same field
- You cannot create custom polymorphic lookups: only Salesforce-defined ones exist
External Objects
Section titled “External Objects”External Objects represent data stored outside Salesforce (in external systems accessed via Salesforce Connect).
| Feature | Standard/Custom Objects | External Objects |
|---|---|---|
| Data storage | On-platform | External system |
| Governor limits | Standard limits | Callout-based limits |
| SOQL | Standard SOQL | Limited SOQL subset |
| Triggers | Full trigger support | Limited (via Change Data Capture change event triggers only) |
| Workflows/Flows | Full support | Limited |
| Relationships | Lookup, MD | External lookup, indirect lookup |
| Real-time data | Yes (stored) | Yes (live query) |
Big Objects
Section titled “Big Objects”Big Objects store and manage massive datasets (billions of records) on the Salesforce platform. Two types exist:
- Standard Big Objects: FieldHistoryArchive, etc.
- Custom Big Objects: Defined with
__bsuffix
Big Object Characteristics
Section titled “Big Object Characteristics”| Feature | Big Objects | Standard/Custom Objects |
|---|---|---|
| Record count | Billions | Millions (with LDV concerns) |
| SOQL | Standard SOQL on indexed fields only (Async SOQL retired Summer 2023 — use Batch Apex or Bulk API) | Standard SOQL |
| DML | database.insertImmediate() | Standard DML |
| Indexes | Defined at creation (immutable) | Configurable |
| Triggers | Not supported | Full support |
| Reporting | Not supported (query into custom objects) | Full support |
| Relationships | Cannot be child in MD | Full support |
CTA Use Cases for Big Objects
Section titled “CTA Use Cases for Big Objects”- Audit trail archival: Move old FieldHistoryArchive records
- Historical data: Transaction history, log data, IoT telemetry
- Data archival: Move aged records from standard objects to preserve performance
Record Types
Section titled “Record Types”Record types enable different business processes, page layouts, and picklist values on the same object.
When to Use Record Types
Section titled “When to Use Record Types”- Different user groups need different page layouts on the same object
- Different picklist values per business process (e.g., Case types for Support vs Engineering)
- Different sales processes for Opportunity (e.g., New Business vs Renewal)
- Different Lead conversion mappings per business unit
When NOT to Use Record Types
Section titled “When NOT to Use Record Types”- Just to filter list views (use list view filters instead)
- When a custom field with values would suffice
- When fundamentally different data models call for separate objects
Person Accounts
Section titled “Person Accounts”Person Accounts merge Account and Contact into a single record for B2C scenarios. This is one of the most consequential data modeling decisions on the platform.
Person Account Internal Architecture
Section titled “Person Account Internal Architecture”Person Accounts are not a new object type. They are a dual-nature entity that creates both an Account record and a Contact record simultaneously. Understanding this internal structure is critical for integration and Apex development.
IsPersonAccount.Person Account Trade-offs
Section titled “Person Account Trade-offs”| Advantage | Disadvantage |
|---|---|
| Natural B2C data model | Irreversible once enabled |
| Unified record for individual | Breaks Account-Contact assumptions in code |
| Account features for individuals (teams, hierarchy) | Many AppExchange packages incompatible |
| Simplifies data model for B2C | Complicates B2B+B2C hybrid orgs |
| Person Account record type distinguishes B2C from B2B | Integration complexity increases |
Formula Fields and Limits
Section titled “Formula Fields and Limits”Formula fields are powerful but consume resources. Key limits:
| Limit | Value |
|---|---|
| Formula field character limit | 3,900 characters (compiled size 5,000) |
| Cross-object references | Up to 10 unique relationships per object (spanning relationships) |
| Formula fields per object | No hard limit, but impacts performance |
| SOQL and formula interaction | Formulas cannot be used in WHERE clauses |
Performance Considerations
Section titled “Performance Considerations”- Formula fields are calculated at read time, adding computation to every query
- Cross-object formulas create implicit dependencies that affect deployment order
- Deterministic formulas (no
NOW(),TODAY()) can be indexed, which matters for LDV - Heavy formula usage on LDV objects degrades list view and report performance
Roll-Up Summary Fields
Section titled “Roll-Up Summary Fields”Roll-up summary fields aggregate child records in a master-detail relationship.
Available Functions
Section titled “Available Functions”- COUNT: Count of detail records
- SUM: Sum of a numeric field
- MIN: Minimum value
- MAX: Maximum value
Limits and Alternatives
Section titled “Limits and Alternatives”| Constraint | Limit |
|---|---|
| Roll-ups per object | 10 per object by default (can be increased to 25 via Salesforce Support) |
| Filter criteria | Supported (count WHERE Status = ‘Closed’) |
| Cross-object formulas | Can reference roll-up values |
| Supported relationships | Master-detail only (native) |
For lookup relationships, alternatives include:
- Declarative Lookup Roll-up Summaries (DLRS): Open-source AppExchange package
- Flow-based roll-ups: Record-triggered flows with aggregation
- Apex triggers: Custom roll-up logic with bulkification
- Salesforce native (beta): Roll-up on lookup is evolving
ERD Patterns for CTA Scenarios
Section titled “ERD Patterns for CTA Scenarios”Classic B2B Sales Model
Section titled “Classic B2B Sales Model”Service Cloud Model with Knowledge
Section titled “Service Cloud Model with Knowledge”Custom Multi-Tenant Model (Common CTA Scenario)
Section titled “Custom Multi-Tenant Model (Common CTA Scenario)”B2C / Person Account Model
Section titled “B2C / Person Account Model”B2B2C Hybrid Model
Section titled “B2B2C Hybrid Model”In a B2B2C model, a business sells through another business to reach consumers. The data model must accommodate both the B2B partner relationship and the B2C consumer relationship.
Data Modeling Anti-Patterns
Section titled “Data Modeling Anti-Patterns”1. God Object
Section titled “1. God Object”Cramming unrelated data into a single object (usually Account or a “master” custom object). This leads to:
- Field count approaching 800 limit
- Confusing page layouts
- Security and sharing nightmares
- Deployment conflicts between teams
2. Over-Normalization
Section titled “2. Over-Normalization”Creating too many objects with narrow responsibilities. On Salesforce, joins are expensive (SOQL limits), and every relationship adds query complexity. Balance normalization with platform realities.
3. Ignoring Sharing Implications
Section titled “3. Ignoring Sharing Implications”Choosing lookup when master-detail is needed for sharing, or vice versa. A lookup relationship means the child has its own sharing model. If children must inherit parent sharing, use master-detail.
4. Late Record Type Addition
Section titled “4. Late Record Type Addition”Adding record types after data is populated requires backfilling all existing records. Plan record types during initial design.
5. Circular Master-Detail
Section titled “5. Circular Master-Detail”Creating A -> B -> C -> A master-detail chains. Salesforce prevents this, but architects sometimes try to work around it with mixed lookup/MD chains, creating confusing ownership and sharing models.
Related Topics
Section titled “Related Topics”- Sharing Model: master-detail vs lookup determines sharing inheritance and OWD impact
- Field & Object Security: field-level security and object permissions constrain data model design
- Integration Patterns: object structure affects API payloads, ETL field mapping, and external ID strategy
- Large Data Volumes: relationship type and formula fields affect query performance at scale
- Data Migration: relationship order dictates migration load sequence
- Development Lifecycle: record types and custom objects affect change management and deployment complexity
- Org Strategy: data model complexity influences single-org vs multi-org decisions
Sources
Section titled “Sources”- Salesforce Architects: Data 360 Architecture
- Salesforce Help: Object Relationships Overview
- Salesforce Help: Considerations for Object Relationships
- Salesforce Help: Big Objects Implementation Guide
- Salesforce Help: Person Accounts
- Salesforce Help: Considerations for Using Person Accounts
- Salesforce Developer: SOQL Polymorphism - TYPEOF
- Salesforce Developer: Working with Polymorphic Relationships in SOQL
- Salesforce Developer: Person Accounts API Guidelines
- Salesforce Architect: Data Model Notation
- Salesforce Architect: Customer Data Models
- Salesforce Developer: B2B Commerce Data Model
- Trailhead: B2B2C Commerce Data Model
- Trailhead: Data Modeling
- CTA Study Guide: Data Domain
Personal study notes for the Salesforce CTA exam. Content compiled from VJ's study notes, official Salesforce documentation, community sources, and online publicly available content, then organized and presented with AI assistance. Not affiliated with Salesforce. © 2025–2026 VJ Srivastava.