0

When I was checking the Account Name field in Contact Object it is appearing as a Lookup(Account) account is parent and contact is child i know those relation ships and behavior
parent to child query ex: account ac =[select id,name ,(select id,anme from contacts) from account]; same like contact is parent and Opportunity child enter image description herebut query from different

List<contact> consobj=[SELECT id,firstname,(SELECT OpportunityId FROM OpportunityContactRoles) ,lastname FROM contact ];

what is difference between Account/Contact and Contact/Opportunity

4

The difference basically lies in how both account and opportunities are related to each other.

Salesforce allows to capture only once account per contact object, which seems legit, its a rare possibilty that a contact is related to multiple Accounts. So we have one-to-many relationship between Account and Contact, viz. one Account can have multiple contacts, but one contact can be associated with only one Account.

Now coming to, opportunityContactRole. It is a junction object between Opportunity and Contact. There is a many-to-many relationship between Opportunity and Contact, through a junction object alled OpportunityContactRole. In an opportunity, you may add many opportunity contact roles and reverse is also true

Hope this clarifies your query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.