You need to sign in to do that
Don't have an account?

Question about creating relationships with Soql
Hi, I am new to SOQL and have a few question about creating parent to child relation with soql. I have created 3 SObject: First SObject contains Child information (Child's name, age, birthdate, School Name, Father's Name), Second Sobject contains School information(School name, Size address), Third contains Father information(Name, Age, Child Name, etc). I was wondering how do relate Child to father and Child to School.
I know how to get the information from one SObject: Public List<Child__c> getChildInfo()
{ return [Select Id, Name, Age__c, Father_Name__c, School_Name__c, Phone_Number__c, Street_Address__c, Zip_Postal_Code__c From Child__c ];}
But how do I List child Father Name and information? Do I need to do something in the custom object link in the setup
Thanks for any help you can give.
This is what will get you started-
Relationships in SOQL
Cool_D
Hi, i'll try to provide a conceptual example just to illustrate the ideas, hope it helps.
First, we have the Father Object
Father {
Id
Name - String
Age? - Integer
Birthdate - Date
}
Child {
Id
Name - String
Age? - Integer
Birthdate - Date
Father - LookUp <- This is important!
}
In the Child object we have a Father field, in the form of a lookup field.
When a child is created, you complete this lookup field with a Father object, SF will let you select from the availables fathers.
In this way, one child can have only one father but a father can have multiple children.
If this isn't enought, just let me know and i'll provide a brief code example.
Hope it helps !!
- Zeta