I covered this post. There I met the following query:
SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c
Here is the explanation provided in the post:
Note that we have utilized a NESTED select to obtain the records of related children from the parent. This kind of expression is very powerful in obtaining related records traversing from the 1 side in a 1-m relationship. In complex data modeling, especially with containment relationships, it is a useful pattern to obtain related information on a parent and all its children via traversing path expressions with relationship fields. In this example, we are utilizing a path expression from Position__c using the relationship, Job_Applications__r to obtain the list of applicants to create this join. This pattern will also be very useful in obtaining data from feeds in Chatter which will be discussed elsewhere. Please note that the result set is a list of positions where each position contains a list of application, reflecting the nature of the hierarchical representation of the data that is selected by this query.And is very useful Information for the beginners.
In order to make my question here I first explain my understanding of the query.
We take all records in
Position__c object. For each present record we are retrieving the
Name of the record at first. Then we are using the taken record and filter out all the records in
Job_Applications__r so that we a left with only those records from
Job_Applications__r which have their field (the API name of which is)
Position__c being equal to the taken record from
Position__c; for every record (with we are left with after screening) from
Job_Applications__r we are retrieving the
Name of the record and assemble a list of the names. As a result we are getting a name of a
Position__c record and a list on names of
Job_Applications__r records associated with it.
Here comes my question: How does
SOQL guarantee that there will be a
Position__c field in
Job_Applications__r? Or what happens if there is no such field?
I may lack the attention and miss something here (I am sorry for that), but after googling for 20 minutes I was not able to find out the answer to my question.