Data Model — Objects, Fields & Relationships

Standard vs custom objects, field types, lookup vs master-detail, junction objects and external IDs.

Admin 2 min readData modelRelationshipsObjectsFields

Objects

  • Standard objects ship with Salesforce: Account, Contact, Lead, Opportunity, Case, User…
  • Custom objects end in __c (API name Invoice__c), custom fields too (Discount__c).
  • Each record has an 18-character case-insensitive Id; the first 3 characters identify the object (001 Account, 003 Contact, 006 Opportunity).

Common field types

TypeExample use
Text / Text Area / Long Text AreaNames, notes
Number / Currency / PercentQuantities, amounts
Picklist / Multi-select picklistStage, Industry
CheckboxActive?
Date / Date/TimeClose date, created date
Formula (read-only)Amount * Probability / 100
Roll-Up Summary (master-detail parent only)Count/sum of child records
Lookup / Master-DetailRelationships
Auto NumberINV-{0000}

Lookup vs Master-Detail

LookupMaster-Detail
CouplingLooseTight (child can't exist without parent)
RequiredOptional (can be required)Always required
Delete parentChild kept (field cleared) or blockedChildren deleted (cascade)
Owner / sharingChild has its own owner and sharingChild inherits owner & sharing from parent
Roll-up summary fields❌ (use Flow/Apex)✅
Per objectUp to 40 relationship fields totalUp to 2 master-detail

Junction objects (many-to-many)

To relate many Students to many Courses, create Enrollment__c with two master-detail fields (Student, Course). Each Enrollment record links one student to one course.

Student__c ──< Enrollment__c >── Course__c

The first master-detail field becomes the "primary" parent (record ownership, look and feel).

Hierarchical & other relationships

  • Self-relationship: Account → Parent Account.
  • Hierarchical: only on User (e.g. Manager).
  • External lookup: to external objects (Salesforce Connect).

External IDs

Mark a text/number/email field as External ID (and often Unique) to:

  • Upsert records from another system without knowing Salesforce Ids.
  • Speed up searches and SOQL filters (the field is indexed).

Schema Builder

Setup → Schema Builder gives a drag-and-drop ERD of objects and relationships — handy for explaining a data model in an interview.

Interview questions

  1. Lookup vs master-detail — give three differences.
  2. How do you model a many-to-many relationship? → Junction object with two master-detail fields.
  3. Can you convert a lookup to master-detail? → Yes, if every existing record has a value in the field.
  4. What is an external ID used for? → Upserts/integrations and indexed lookups.

Practice this