1

I have a requirement, want to know a good approach to address that problem.

We have a data model where we will have to create many to many relations. I am just thinking that i can create one junction object instead of creating one for each many to many relation.

Example: Let's say i have 6 custom objects in my database. 6th custom object has many-to-many relation with all other 5 custom objects. I will create 5 junction objects. My question here is that 1. Why Can't i create one junction object which will replace all other 5 junction objects?

Let me know if you need more info. I am happy to provide. Any suggestions/ideas would be much appreciated.

Thanks Ashok.

  • 1
    Please provide a more detailed explanation of your data model. As is this question is not possible to provide useful answers to. – Adrian Larson Jan 16 '15 at 18:33
  • @Adrian - Let's say i have 6 custom objects in my data model. 6th custom object has many-to-many relation with other 5 custom objects. What i will do, i will create 5 junction objects. if the number increases, i will end up creating more junction objects. I want to know that this is the right approach or is there any design pattern for this kind of requirement. Let me know if you need more info. I am happy to provide. – Ashok Jan 16 '15 at 18:41
  • I would say : create several junction object. It's a better approach and you could add two master detail relation between your two main objects in order to delete the junction record if one of the parent is deleted. Otherwise, you will have a lot of dirty records. – Yann Gorvel Jan 20 '15 at 14:27
2

I would create separate many-to-many objects, any other solution would also remove standard many-to-many features as you can only create 2 master-detail relationships.

Sure you could have a custom object with a lot of lookup's that you re-use, what your choice and solution should come down to is essentially based on what functionality and features you truly need and what limits you have within your org. Do also consider maintainability.

Based on the Considerations for Relationships you also want to think about sharing settings, delete functionality, reporting, ..

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.