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

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .