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 nameInvoice__c), custom fields too (Discount__c). - Each record has an 18-character case-insensitive Id; the first 3 characters identify the object (
001Account,003Contact,006Opportunity).
Common field types
| Type | Example use |
|---|---|
| Text / Text Area / Long Text Area | Names, notes |
| Number / Currency / Percent | Quantities, amounts |
| Picklist / Multi-select picklist | Stage, Industry |
| Checkbox | Active? |
| Date / Date/Time | Close date, created date |
| Formula (read-only) | Amount * Probability / 100 |
| Roll-Up Summary (master-detail parent only) | Count/sum of child records |
| Lookup / Master-Detail | Relationships |
| Auto Number | INV-{0000} |
Lookup vs Master-Detail
| Lookup | Master-Detail | |
|---|---|---|
| Coupling | Loose | Tight (child can't exist without parent) |
| Required | Optional (can be required) | Always required |
| Delete parent | Child kept (field cleared) or blocked | Children deleted (cascade) |
| Owner / sharing | Child has its own owner and sharing | Child inherits owner & sharing from parent |
| Roll-up summary fields | ❌ (use Flow/Apex) | ✅ |
| Per object | Up to 40 relationship fields total | Up 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
- Lookup vs master-detail — give three differences.
- How do you model a many-to-many relationship? → Junction object with two master-detail fields.
- Can you convert a lookup to master-detail? → Yes, if every existing record has a value in the field.
- What is an external ID used for? → Upserts/integrations and indexed lookups.