I have this user case where a community user needs to see the appointments of all the contacts in his parent account.Appointment has a lookup relationship to contact. Right now, in the first soql query I am getting the contactid of the user.
myContact=[select id,email, from contact where id =:loggdinUserRecord.contactid];
Then I am running a query to get the account id of that contact:
con=[select account.name,account.id from contact where id=:myContact.id];
and in the third and fourth query, I am getting the contact names for each of those accounts and the appointment for each of those contacts.
Is this how it's supposed to be or can I optimize the soql queries to make it more efficient?