Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
DictionaryCChild Relationship
DevelopmentIntermediate

Child Relationship

A Child Relationship in Salesforce describes the connection from a child object to a parent object in a master-detail or lookup relationship.

§ 01

Definition

A Child Relationship in Salesforce describes the connection from a child object to a parent object in a master-detail or lookup relationship. The child object contains the relationship field that points to the parent. Child relationships are referenced in SOQL subqueries using the relationship name (e.g., querying Contacts as a child relationship of Account). The relationship name is used for building queries, related lists, and cross-object formulas.

§ 02

In plain English

👋 Study buddy

A Child Relationship in Salesforce is the connection from the child object back to its parent. For example, Contacts have a child relationship to Account. The relationship has a name that you use when writing SOQL queries to grab all the children of a parent in one query.

§ 03

Worked example

scenario · real-world use

When a developer at Larkfield Capital writes SOQL to fetch an Account and all its Contacts in one query, she uses the Child Relationship: SELECT Id, Name, (SELECT Id, Email FROM Contacts) FROM Account WHERE Id = '...'. The inner subquery references the relationship name "Contacts" - the Child Relationship name on Account pointing back at Contact. Child Relationship names are configured when the lookup or master-detail field is created (the default for Contact-on-Account is "Contacts"). They're used in SOQL subqueries, in cross-object formulas, and in the Account page's related-list rendering.

§ 04

Why Child Relationship matters

A Child Relationship describes the perspective from a child object looking back at its parent in a master-detail or lookup relationship. Every relationship in Salesforce has two sides: the parent looks down at children through the Child Relationship, and the child looks up at the parent through the lookup or master-detail field. The Child Relationship has a name (configured when the relationship is defined) that's used in SOQL subqueries, related lists, and cross-object formulas to navigate from parent to children.

In SOQL, you use the Child Relationship name in a subquery like this: SELECT Id, Name, (SELECT Id, FirstName, LastName FROM Contacts) FROM Account. The 'Contacts' inside the parentheses is the Child Relationship name on Account that points back to all related Contact records. Child Relationship names are typically the plural form of the child object name (Contacts, Opportunities, Cases) for standard objects, and admins choose them for custom objects when defining the relationship field. Picking a clear, plural Child Relationship name is important because it shows up in SOQL queries throughout the codebase.

§ 05

How organizations use Child Relationship

Quantum Labs

Uses a Child Relationship name they defined as 'Project_Members__r' on a custom Project__c object to query all related Project Member records in a single SOQL query. The relationship name is consistent across the codebase.

TerraForm Tech

Renamed a Child Relationship after discovering the auto-generated name was inconsistent with their naming convention. The rename required updating every SOQL query that used the old name, which was a useful reminder to choose names carefully upfront.

CodeBridge

Documented every custom Child Relationship name in their data dictionary so developers know what to use in queries without having to look it up in the field metadata each time.

Was this entry helpful?
Help us write better definitions. Quick reactions or detailed edit suggestions.
§

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…

Loading discussion…