One-to-Many Relationship
A one-to-many relationship in Salesforce is a data model pattern where one parent record can have many related child records, but each child record belongs to exactly one parent.
Definition
A one-to-many relationship in Salesforce is a data model pattern where one parent record can have many related child records, but each child record belongs to exactly one parent. The relationship is implemented through a lookup or master-detail field on the child object that points to the parent. Common examples are Account to Contact (one Account, many Contacts), Account to Opportunity (one Account, many Opportunities), Opportunity to OpportunityLineItem (one Opportunity, many line items), and Case to CaseComment.
Salesforce supports two flavors of one-to-many: lookup (loose coupling, child can exist without parent, parent deletion does not cascade) and master-detail (tight coupling, child is owned by parent, parent deletion cascades to children). Choose lookup for optional relationships where children sometimes have no parent; choose master-detail when the child has no meaning without the parent and ownership and sharing should inherit from the parent.
How one-to-many relationships work in the Salesforce data model
Lookup versus master-detail
Lookup is the loose-coupling version. The child object has a Lookup field pointing to the parent; the field can be null, meaning the child exists without a parent. Master-detail is the tight-coupling version. The Master-Detail field cannot be null; deleting the parent deletes every child; the child inherits the parent ownership and sharing rules. A given object can have up to 2 master-detail fields (which makes it a junction object for many-to-many) and up to 40 total relationship fields (including lookups). The choice between the two is one of the most consequential data-modeling decisions in any Salesforce implementation.
Where the relationship is stored
The relationship field always lives on the many side (the child). One Account has many Contacts, so the AccountId field lives on Contact, not Account. This pattern is universal in relational databases; Salesforce mirrors it directly. Reports, list views, and SOQL queries traverse the relationship through the child field name (Contact.AccountId in SOQL, Contact.Account.Name to navigate up to a parent field).
Roll-up summary fields
On a master-detail relationship, the parent object can have a Roll-Up Summary field that aggregates child records: count of children, sum of a field, max, min. This is one of the biggest reasons to choose master-detail over lookup. A common pattern is Opportunity Amount as a roll-up summary of OpportunityLineItem TotalPrice. Lookups do not support native roll-up summaries; the same pattern requires Apex triggers, scheduled batch jobs, or Declarative Lookup Rollup Summaries (an AppExchange free tool) to compute.
Sharing and access inheritance
Master-detail children inherit the parent record sharing automatically. A user with read access to the Account sees every Contact under that Account, regardless of the user own Contact-level sharing rules. Lookup relationships do not auto-inherit; children have their own sharing model. For sensitive data, master-detail simplifies sharing but also reduces flexibility (you cannot grant access to only some children of a parent without breaking the inheritance).
Converting lookup to master-detail and back
Salesforce supports converting lookup to master-detail (and back) under specific conditions. Going from lookup to master-detail requires every child record to already have a value in the field (no nulls allowed in master-detail) and the field to be configured correctly. Going from master-detail to lookup is simpler but breaks the roll-up summaries and the sharing inheritance. Plan conversions during a deploy window and test the downstream effects (reports, dashboards, automation) in a sandbox.
Special standard one-to-many relationships
Salesforce ships hundreds of standard one-to-many relationships. Account to Contact, Opportunity, Case, Asset, and Order. Lead has no parent (Lead is converted to Account and Contact). Contact has the unusual ability to be related to multiple Accounts via AccountContactRelation (a many-to-many bridge), but the primary AccountId on Contact remains a one-to-many lookup. Read the Schema Builder or Object Reference to understand the standard relationships before adding custom ones; many problems have already been solved by Salesforce.
How to create a one-to-many relationship in Salesforce
Create the relationship from the child object Fields & Relationships area in Object Manager. Decide lookup or master-detail before starting; converting later is possible but disruptive.
- Open the child object in Object Manager
Setup > Object Manager > [child object name] > Fields & Relationships. Click New.
- Pick the field type
Select Lookup Relationship for loose coupling or Master-Detail Relationship for tight coupling. Click Next.
- Select the related parent object
Pick the object that should be the One side of the relationship. Click Next. The field will be created on the current (Many) object and pointed at the parent.
- Set field label, name, and behavior
Enter the field label and API name. For Lookup, choose what happens when the parent is deleted: Clear the value of this field (default), Do not allow deletion of the parent (most strict), Delete this record also (cascade). For Master-Detail, no choice; cascade is automatic.
- Configure field-level security and page layouts
Pick which profiles see the field. Add the field to relevant page layouts. Save. The relationship is live; child records can now point to parents through this field.
Loose coupling. Child can have no parent. Parent deletion does not cascade by default.
Tight coupling. Child cannot exist without parent. Cascade delete and sharing inheritance built in.
Special lookup on the User object only, pointing to another User. Used for the manager hierarchy.
Relationship from a Salesforce object to an external object (Salesforce Connect). Read-only by default.
- Master-detail fields are required and cascade-deleting. Adding one to an existing object with thousands of records requires every record to already have a value; you cannot leave any null.
- Each custom object can have at most 2 master-detail fields. If you need three, the third must be a lookup, or restructure the model with junction objects.
- Roll-up summary fields only work on master-detail relationships. Convert lookup to master-detail (or use the Declarative Lookup Rollup Summary tool) if you need aggregates.
- Standard objects have specific limits on which relationships are allowed. You cannot create a master-detail from a custom object to a User, for example. Check the Object Reference before designing.
Trust & references
Cross-checked against the following references.
- Object Relationships OverviewSalesforce Help
- Relationship Field ConsiderationsSalesforce Help
Straight from the source - Salesforce's reference material on One-to-Many Relationship.
- Custom Object RelationshipsSalesforce Help
- Relationships Among Objects API ReferenceSalesforce Developers
Hands-on resources to go deeper on One-to-Many Relationship.
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What is a One-to-Many Relationship?
Q2. How is it implemented?
Q3. When use Master-Detail over Lookup?
Discussion
Loading discussion…