You need to sign in to do that
Don't have an account?
Nicole Chang_
Master detail vs lookup
Hello everyone,
From what I understand, only way to create many-to-many between objects is creating junction object.
however I was looking at the schema builder and noticed that there's lookup from opportunities to contracts, and another lookup from contracts to opportunities, with that many-to-many also created between opportunities & contracts.
Still trying to wrap my head around it, though I feel like I am missing something here, does that mean we can:
1. Create many to many without any junction object?
2. Lookup also can be used for many-to-many?
Thanks so much in advance!!
From what I understand, only way to create many-to-many between objects is creating junction object.
however I was looking at the schema builder and noticed that there's lookup from opportunities to contracts, and another lookup from contracts to opportunities, with that many-to-many also created between opportunities & contracts.
Still trying to wrap my head around it, though I feel like I am missing something here, does that mean we can:
1. Create many to many without any junction object?
2. Lookup also can be used for many-to-many?
Thanks so much in advance!!
1. You need to create a junction object for many to amy relationship.
Refer the help artilce.
https://help.salesforce.com/s/articleView?id=sf.relationships_manytomany.htm&type=5
2. You can achieve the many to many relationship using lookup relationship but as the function with master detail relationship when parent record is deleted its child are also deleted this wont happen in lookup relationship. Even if You make the lookup field in lookup relationship required then when you delete parent record it will give an error as it is been used in junction Object . Its better to have Masterdetail relationship on junction Object to have many to many relationship, that even when the parent record is deleted that relationship also get deleted in junction Object.
Refer the below help article for relationship considerations in salesforce.
https://help.salesforce.com/s/articleView?id=sf.relationships_considerations.htm&type=5
If this information helps, Please mark it as best answer.
Thanks!!
All Answers
1. You need to create a junction object for many to amy relationship.
Refer the help artilce.
https://help.salesforce.com/s/articleView?id=sf.relationships_manytomany.htm&type=5
2. You can achieve the many to many relationship using lookup relationship but as the function with master detail relationship when parent record is deleted its child are also deleted this wont happen in lookup relationship. Even if You make the lookup field in lookup relationship required then when you delete parent record it will give an error as it is been used in junction Object . Its better to have Masterdetail relationship on junction Object to have many to many relationship, that even when the parent record is deleted that relationship also get deleted in junction Object.
Refer the below help article for relationship considerations in salesforce.
https://help.salesforce.com/s/articleView?id=sf.relationships_considerations.htm&type=5
If this information helps, Please mark it as best answer.
Thanks!!