πŸ”—

Data Modeling and Management

MD vs Lookup relationships, junction objects, field types, record types, Schema Builder, data quality, and custom metadata types.

⏱️ Estimated reading time: 55 minutes

Master-Detail vs Lookup: The Ultimate Comparison

Relationships are the heart of data modeling in Salesforce and represent the most asked exam area in the Data Modeling domain.

Complete comparison table:

FeatureMaster-Detail (MD)Lookup
Required parent fieldβœ… Yes, always❌ No, can be blank
Cascade deleteβœ… Automatic (children deleted)❌ No (orphan records created)
Roll-Up Summary Fieldsβœ… Available natively❌ Not native (use Flow or Apex)
Child record OWDInherited from parentIndependent from parent
Maximum per object240
Reparenting (change parent)Configurable (disabled by default)βœ… Always possible
Child ownershipControlled by parentOwn and independent
Required fieldAlways requiredConfigurable
Standard Objects as child❌ Cannot createβœ… Yes

Hierarchical Relationship:
Special Lookup type that exists ONLY on the User object. Creates reporting hierarchies (Manager β†’ Employee). Used to define reporting chains and for hierarchy-based Sharing Rules.

Self-Relationship:
A Lookup relationship where an object relates to itself. Example: Parent Account β†’ Child Account (Account Hierarchy). Useful for modeling corporate structures.

Converting between types:
- Lookup β†’ Master-Detail: Possible ONLY if all child records already have a value in the parent field (no null values).
- Master-Detail β†’ Lookup: Possible at any time.

Golden exam rule:
- Need Roll-Up Summary or cascade delete? β†’ Master-Detail
- Is the parent field optional or do you need independent OWD? β†’ Lookup
- Is the child a Standard Object (Account, Contact, etc.)? β†’ Lookup (MD doesn't allow standard objects as children)

🎯 Key Points

  • βœ“ Master-Detail: required parent, cascade, Roll-Up Summary, inherited OWD, max 2 per object
  • βœ“ Lookup: optional parent, no cascade, no native Roll-Up, independent OWD, max 40 per object
  • βœ“ Hierarchical Relationship only exists on the User object
  • βœ“ To convert Lookup to MD, all children must have an assigned parent (no nulls)
  • βœ“ Cannot create Master-Detail where the child is a Standard Object

Junction Objects and Many-to-Many Relationships

Salesforce does not support direct many-to-many relationships. The solution is to create a Junction Object with two Master-Detail relationships.

Practical example: Student ↔ Course
1. Create custom object Enrollment__c (Junction Object).
2. Master-Detail #1: Enrollment__c β†’ Student__c (primary parent).
3. Master-Detail #2: Enrollment__c β†’ Course__c (secondary parent).

Junction Object behavior:
- The first Master-Detail created is the primary parent and controls:
- The OWD (Organization-Wide Default) of the Junction Object.
- The look-and-feel of the Junction Object's tab.
- The first Lookup in Data Loader operations.
- Both parents can show Related Lists from the Junction Object.
- Both parents can have Roll-Up Summary Fields calculating data from the Junction.
- Additional fields can be added to the Junction Object to store relationship data (e.g., Grade__c, Enrollment_Date__c, Status__c).

Other common Junction Object examples (asked in the exam):
- OpportunityLineItem (Standard): Junction between Opportunity and Product2.
- CampaignMember (Standard): Junction between Campaign and Lead/Contact.
- Project_Assignment__c (Custom): Junction between Employee__c and Project__c.

Important rules:
- A Junction Object needs exactly 2 Master-Detail relationships.
- An object can be a parent in multiple Junction Objects.
- You cannot create more than 2 Master-Detail on the same object.
- Related Lists on both parents automatically show Junction Object fields.

🎯 Key Points

  • βœ“ Junction Object = object with exactly 2 Master-Detail relationships
  • βœ“ The first MD created is the primary parent (controls OWD and security)
  • βœ“ Roll-Up Summary available on both parent objects
  • βœ“ OpportunityLineItem and CampaignMember are standard Junction Objects
  • βœ“ Custom fields can be added to the Junction for relationship data

Field Types: Formulas, Roll-Up Summary, Picklists, and More

Deep knowledge of field types is essential for the exam.

Formula Fields:
- Read-only fields that calculate a value based on other fields.
- Support cross-object formulas: access parent fields (e.g., Account.Industry).
- Can cross up to 10 levels of relationships.
- Limit: 5,000 compiled characters (not visible characters, but compiled).
- Return types: Text, Number, Date, DateTime, Checkbox, Percent, Currency.
- CANNOT be used in: Record-Triggered Flow criteria (before save), or as report sorting fields.

Most asked formula functions:
- ISBLANK(field) / ISNULL(field): Checks if a field is empty. Use ISBLANK (ISNULL is legacy).
- ISPICKVAL(picklist, 'value'): Compares picklists. Do NOT use = for picklists.
- TEXT(picklist): Converts picklist to text for text operator usage.
- PRIORVALUE(field): Value before the change (updates only).
- ISCHANGED(field): TRUE if the field changed (updates only).
- ISNEW(): TRUE if the record is being created (not updated).
- CASE(field, 'val1', result1, 'val2', result2, default): Switch/equivalence.
- IF(condition, trueValue, falseValue): Basic conditional.
- HYPERLINK(url, label): Creates a clickable link.
- IMAGE(url, alt): Displays an image.
- NOW() vs TODAY(): NOW = current DateTime, TODAY = date only.
- DATEVALUE(dateTime): Extracts the date part from a DateTime.
- YEAR(), MONTH(), DAY(): Extract date parts.

Roll-Up Summary Fields:
- Calculate aggregate values on the parent object based on child records in a Master-Detail relationship.
- Available operations: COUNT, SUM, MIN, MAX.
- Filter criteria can be applied (e.g., only count 'Closed Won' opportunities).
- NOT available on Lookup relationships (use Flow to simulate).
- Only created on the parent object, never on the child.

Picklists:
- Standard Picklist: Simple value list.
- Multi-Select Picklist: Allows selecting multiple values (semicolon-separated). Has limitations: can't easily use in report criteria, doesn't support ISPICKVAL.
- Global Value Set: Reusable value set shared across multiple picklists on different objects. Changing a value in the Global Set changes it on all fields using it.
- Dependent Picklist: A picklist that displays different values based on another picklist's selection (controlling field). The controlling field can be a standard picklist or a checkbox.

Other important fields:
- Auto-Number: Generates sequential number automatically (e.g., CASE-{0000}). Read-only.
- External ID: Indexed field for identifying records in integrations. Enables Upsert operations. Maximum 7 External IDs per object. Text, Number, or Email fields can be External ID.
- Encrypted Field (Classic): Encrypted text field. Only users with 'View Encrypted Data' permission can see the value.
- Geolocation: Stores latitude and longitude coordinates.

🎯 Key Points

  • βœ“ Formula Fields: read-only, cross-object (up to 10 levels), 5,000 compiled chars limit
  • βœ“ Roll-Up Summary: ONLY on Master-Detail, COUNT/SUM/MIN/MAX operations, created on parent
  • βœ“ Use ISPICKVAL() to compare picklists, NEVER the = operator
  • βœ“ ISCHANGED() and PRIORVALUE() only work on updates, NOT on record creation
  • βœ“ External IDs enable Upsert and are key for integrations (max 7 per object)
  • βœ“ Global Value Sets allow reusing the same value list across multiple objects

Record Types and Business Processes

Record Types allow offering different business processes, picklist values, and page layouts for different types of records within the same object.

When to use Record Types?
- When different user groups need to see different fields or layouts for the same object.
- When an object serves multiple purposes (e.g., 'Account' can be Customer, Vendor, or Partner).
- When you need different picklist values based on context.

Record Types control:
1. Page Layouts: Different page designs per Record Type + Profile.
2. Picklist Values: Each Record Type can display a different subset of picklist values.
3. Business Processes: For Opportunity (Sales Process), Lead (Lead Process), Case (Support Process).

Business Processes:
Subsets of standard stages for certain objects:

ObjectProcessControlled Field
OpportunitySales ProcessStage (StageName)
LeadLead ProcessLead Status
CaseSupport ProcessCase Status
SolutionSolution ProcessSolution Status

Example: You can have a Sales Process 'Enterprise Sales' with detailed stages (Prospecting β†’ Qualification β†’ Proposal β†’ Negotiation β†’ Closed Won/Lost) and another 'Quick Sales' with only 3 stages (New β†’ In Progress β†’ Closed).

Record Type Assignment:
- Record Types are assigned to Profiles (and Permission Sets with the correct permission).
- A profile can have a default Record Type per object.
- If a profile only has access to one Record Type, the Record Type selector is NOT shown when creating a record.
- If a profile has access to multiple Record Types, a selector appears when creating.

Page Layout Assignment:
Page Layout assignment is a matrix of Record Type Γ— Profile. Each combination can have a different layout.

Example:
Sales ProfileSupport ProfileAdmin Profile
RT: CustomerSales-Customer LayoutSupport-Customer LayoutAdmin Layout
RT: VendorSales-Vendor LayoutSupport-Vendor LayoutAdmin Layout

🎯 Key Points

  • βœ“ Record Types control: Page Layouts, Picklist values, and Business Processes
  • βœ“ Business Processes: Sales Process (Opportunity), Lead Process (Lead), Support Process (Case)
  • βœ“ Page Layout Assignment is a Record Type Γ— Profile matrix
  • βœ“ If a profile has only 1 Record Type, the selector does NOT appear when creating records
  • βœ“ Record Types are assigned to Profiles, not individual users

Schema Builder and Data Import/Export

Schema Builder:
Visual tool showing objects, fields, and relationships as an interactive entity-relationship diagram.

What Schema Builder CAN do:
- Visualize relationships between objects (Standard and Custom).
- Create new custom objects directly in the diagram.
- Create new fields by dragging the field type to the object.
- View data type, API name, and label for each field.
- Filter which objects are displayed in the diagram.

What Schema Builder CANNOT do (frequent question):
- ❌ Create validation rules.
- ❌ Create flows or automations.
- ❌ Create page layouts.
- ❌ Create triggers or code.
- ❌ Import or export data.
- ❌ Create Record Types.

Data Import Tools:

FeatureData Import WizardData Loader
Record limit50,000Millions
InterfaceWeb (within Setup)Desktop application / CLI
Supported objectsAccounts, Contacts, Leads, Solutions, Custom ObjectsAll objects
Deduplicationβœ… Built-in (by Salesforce ID, Name, Email)❌ Manual
OperationsInsert, Update, UpsertInsert, Update, Upsert, Delete, Hard Delete, Export, Export All
Schedulable❌ Noβœ… Yes (command line)
Import Accounts+Contacts togetherβœ… Yes❌ Separately
External ID for matchingβœ… Yesβœ… Yes

When to use each tool?
- Data Import Wizard: Simple imports under 50,000 records, especially Accounts, Contacts, or Leads. Perfect for non-technical users.
- Data Loader: Massive imports, scheduled operations, data deletion, or when working with objects DIW doesn't support.

Upsert Operation (Update + Insert):
Combines update and insert in a single operation. Uses an External ID or Salesforce ID for matching:
- If it finds an existing record with that ID β†’ Update.
- If not found β†’ Insert (creates new record).

Data Export:
- Data Export Service: Native Salesforce tool for exporting all org data as CSV files. Available weekly (Professional) or monthly. Accessed from Setup.
- Data Loader Export: Exports records from a specific object with SOQL filters.
- Reports: Can also export data as CSV.

🎯 Key Points

  • βœ“ Schema Builder: visual, creates objects and fields β€” does NOT create validations, flows, or page layouts
  • βœ“ Data Import Wizard: up to 50,000 records, built-in deduplication, web interface
  • βœ“ Data Loader: millions of records, all operations (Delete, Hard Delete), schedulable
  • βœ“ Upsert = Update + Insert using External ID or Salesforce ID
  • βœ“ Data Import Wizard can import Accounts + Contacts simultaneously

Data Quality: Duplicate and Matching Rules

Maintaining clean data is critical in Salesforce. The exam asks about native data quality tools.

Duplicate Rules:
Control what happens when a user tries to create or edit a record that is a duplicate.

Configurable actions:
- Alert: Shows a warning to the user but allows saving.
- Block: Prevents the record from saving if it's a duplicate.
- Different actions can be configured for creation vs update.

Matching Rules:
Define the criteria for identifying potential duplicates. A Matching Rule specifies which fields to compare and with what logic.

Match types:
- Exact: Values must be identical.
- Fuzzy: Allows approximate matches (e.g., 'Jon' vs 'John', 'Acme Inc' vs 'Acme Inc.').

Salesforce includes preconfigured Standard Matching Rules for Account, Contact, and Lead using fuzzy matching on fields like Name, Email, Street, City, Phone.

Relationship between Duplicate Rules and Matching Rules:
1. Create a Matching Rule defining comparison criteria.
2. Create a Duplicate Rule referencing the Matching Rule and defining the action (Alert or Block).
3. When a user saves a record, Salesforce executes the Matching Rule β†’ if duplicates detected β†’ applies the Duplicate Rule's action.

Merge (Record Merging):
- Up to 3 Accounts or 3 Contacts or 3 Leads can be merged at once.
- When merging, a master record is chosen and the others are deleted.
- Related records (Opportunities, Cases, etc.) are reassigned to the master record.
- Master record fields are kept, but values from other records can be selected.

Other data quality concepts:
- Mass Transfer Records: Tool for changing the owner of multiple records at once.
- Mass Delete Records: Delete records in bulk based on search criteria.
- Recycle Bin: Deleted records remain in the recycle bin for 15 days and can be restored.

🎯 Key Points

  • βœ“ Duplicate Rule defines the ACTION (Alert or Block); Matching Rule defines the comparison CRITERIA
  • βœ“ Standard Matching Rules use fuzzy matching for Account, Contact, and Lead
  • βœ“ Up to 3 records can be merged at once (Accounts, Contacts, or Leads)
  • βœ“ When merging, related records are reassigned to the master record
  • βœ“ Recycle Bin retains deleted records for 15 days

Custom Settings vs Custom Metadata Types

Both store custom configurations, but have crucial differences for the exam.

Custom Settings:
- Store configuration data at the organization, profile, or user level.
- Two types:
- List Custom Settings: Reusable data set (like a configuration table). Accessed with getAll(), getInstance(name) methods.
- Hierarchy Custom Settings: Have Org β†’ Profile β†’ User hierarchy. The most specific value wins. Accessed with getInstance() which automatically respects the hierarchy.
- They are data (not metadata), so they are NOT automatically migrated with Change Sets.
- Can be accessed in formulas with $Setup.SettingName__c.Field__c.

Custom Metadata Types (CMT):
- Store configurations as metadata (not as data).
- Suffix __mdt on the type name.
- Main advantage: They deploy with Change Sets and packages like any metadata.
- Can be used in:
- Formulas: $CustomMetadata.Type__mdt.Record__mdt.Field__c
- Validation Rules
- Flow Builder (Get Records)
- Apex code
- They are Salesforce's recommended option for deployable configurations.

Exam comparison:

FeatureCustom SettingsCustom Metadata Types
Data typeData (records)Metadata
Migratable with Change Sets❌ No (only structure, not data)βœ… Yes (structure + records)
Hierarchy supportβœ… Yes (Hierarchy type)❌ No
Formula accessβœ… $Setupβœ… $CustomMetadata
SOQL to queryβœ… Yesβœ… Yes (doesn't count against SOQL limits)
Salesforce recommendationLegacy (use CMT)βœ… Preferred

Exam rule: If a question mentions configurations that need to be deployed between environments β†’ Custom Metadata Types. If you need different values per profile/user β†’ Hierarchy Custom Setting.

🎯 Key Points

  • βœ“ Custom Metadata Types deploy with Change Sets (they're metadata); Custom Settings do NOT (they're data)
  • βœ“ Hierarchy Custom Settings: different values per Org/Profile/User (hierarchy)
  • βœ“ Custom Metadata Types are Salesforce's preferred and recommended option
  • βœ“ CMT queries do NOT count against the SOQL per-transaction limit
  • βœ“ If you need to deploy configurations between environments β†’ Custom Metadata Types