How do Lookup relationships differ from Master-Detail relationships in terms of record dependency and security?
Answer
Basics: A lookup field is simply a pointer to another record, for example Contact to Account or a custom Project to Account. It models "is related to" rather than "belongs to".
How it works:
- The field can be optional (default) or required.
- Each child has its own Owner and its own sharing based on its own organization-wide default.
- Deletion behavior when the parent is deleted: Clear the value (default), Don't allow deletion (restrict, so the parent cannot be deleted while children exist), or, for certain custom-object cases, cascade delete (enable-by-request in some orgs).
- Lookup filters can limit which parent records are selectable.
Advanced / deep dive: Comparison:
- Dependency: lookup optional; master-detail required.
- Security: lookup child has own owner/OWD; master-detail child inherits parent sharing.
- Roll-ups: native roll-up summary fields work only on master-detail. For lookup, use a record-triggered flow, an Apex trigger with aggregate queries (
SELECT ParentId, SUM(Amount__c) ... GROUP BY ParentId), Declarative Lookup Rollup Summaries (open source), or a Data Cloud/CRM Analytics approach. - Limits: an object can have a larger number of lookups than master-detail (two), though total relationship counts are limited; verify against the object's limits.
- Reporting: both enable cross-object reports through report types; "with/without" is available through relationships.
- Conversion: lookup to master-detail requires every record to have a parent. Master-detail to lookup requires removing roll-ups and is allowed afterward.
- Self-lookup and polymorphic (WhoId/WhatId) are lookup-type behaviors.
Code / config example:
apex