Child Relationship
A Child Relationship in Salesforce is the schema connection from a parent object back to a child object that references it through a lookup or master-detail field.
Definition
A Child Relationship in Salesforce is the schema connection from a parent object back to a child object that references it through a lookup or master-detail field. Where the parent-to-child reference is just a lookup field on the child, the Child Relationship is the metadata that lets you walk from the parent record back to its many children. SOQL exposes this through the Child Relationship Name: SELECT Id, (SELECT Id FROM Cases) FROM Account walks from Account to its Case children. Apex describes the relationship through DescribeFieldResult's getRelationshipName method. Reports use it to join parent and child for multi-level data display.
Child Relationships matter because they make parent-side traversal possible. Without them, code could find a Case's Account but not an Account's Cases (except via SOQL on Case filtered by AccountId, which is awkward). With them, the schema is bidirectional in practice. Each lookup or master-detail field automatically generates a Child Relationship Name; admins customise the name on the field definition. Most production schemas inherit defaults; sophisticated apps customise names to make code and reports more readable. The Child Relationship Name appears throughout SOQL subqueries, related lists, dynamic Apex, and metadata references.
How Child Relationships shape Salesforce schema and code
Lookup fields and auto-generated relationships
Every lookup or master-detail field generates a Child Relationship from the parent object back to the child. The field definition exposes the Child Relationship Name (defaults to the plural form of the child object, e.g. Cases on Account, Contacts on Account). Admins can customise the name in the field's Relationship Name property.
SOQL subqueries
The most common use of Child Relationships is SOQL subqueries: SELECT Id, (SELECT Id, Subject FROM Cases) FROM Account. The inner query uses the Child Relationship Name (Cases) rather than the child object name. Each parent record returns a list of matching children.
Apex traversal
Apex code accesses children through the relationship name: account.Cases gives the list of Case records returned by the subquery. The schema sObject describe API exposes Child Relationships through getChildRelationships, which lets dynamic code walk relationships without hard-coded names.
Custom relationship names
The default Child Relationship Name is the plural of the child object. Custom objects like Project_Update__c on Project__c default to Project_Updates__r on Project__c. Admins frequently customise these names for clarity: a self-referencing object's children might be called Sub_Tasks__r rather than the awkward Tasks1__r the platform might choose.
Related lists and Child Relationships
The standard Related List component on Lightning record pages renders Child Relationships as related-list sections. Customising the Child Relationship Name also affects how the related list is labelled (until overridden in the page layout).
Self-referencing relationships
Self-referencing relationships (Account.ParentId, Case.ParentId) generate Child Relationships where the parent and child are the same object. The naming gets tricky: the platform's default Tasks1 or similar suffix often needs manual customisation for readability.
Polymorphic Child Relationships
Some relationships are polymorphic: Task.WhatId can point to many object types. The Child Relationship name varies per parent object (Account.Tasks, Opportunity.Tasks). Apex querying polymorphic relationships needs care to handle the parent type appropriately.
Common naming and traversal pitfalls
Three patterns recur. Default Child Relationship Names with awkward numbering (Tasks1, Contacts2) confuse developers; rename at field creation. SOQL subqueries with non-existent relationship names produce confusing errors; the Schema Builder is the fastest way to find the correct name. And deep relationship traversal can hit governor limits if subqueries return huge child lists.
How to use Child Relationships effectively
Child Relationships are mostly automatic. The work is naming them well and using them correctly in code and reports.
- Set Child Relationship Names at field creation
When creating a lookup or master-detail field, set the Child Relationship Name to something readable. Defaults work but customisation pays off for life.
- Use SOQL subqueries to walk children
For parent-to-child queries, use the subquery syntax: SELECT Id, (SELECT Id FROM Cases) FROM Account. The relationship name in parentheses is the Child Relationship Name.
- Access children in Apex through the relationship name
account.Cases returns the list of Cases from a subquery. The name matches the Child Relationship Name set on the field.
- Inspect relationships through Schema Builder
When unsure of a relationship name, open Schema Builder and click the field. The Child Relationship Name appears on the field properties.
- Customise self-referencing relationships
Self-referencing lookups (ParentId on Account) need explicit naming. The platform default is rarely readable; rename to something clear like ChildAccounts.
- Default Child Relationship Names with awkward numbering confuse developers. Rename at field creation.
- SOQL subqueries error on non-existent relationship names. Inspect through Schema Builder if uncertain.
- Deep subqueries can return huge child lists and hit governor limits. Filter the subquery or use separate queries for large data sets.
- Polymorphic relationships (Task.WhatId) expose Child Relationship names per parent object. Apex code needs care to handle the parent type appropriately.
Trust & references
Cross-checked against the following references.
- SOQL Relationship QueriesSalesforce Developer Docs
- Lookup RelationshipsSalesforce Help
Straight from the source - Salesforce's reference material on Child Relationship.
- DescribeFieldResultApex Developer Guide
Hands-on resources to go deeper on Child 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 Child Relationship?
Q2. Where is the Child Relationship name used most often?
Q3. Why should you choose Child Relationship names carefully?
Discussion
Loading discussion…