1

Imagine having a company A (acting as a user) inputing their competitors (picking from a list of other companies).

Company A stated they compete with Company B, Company C and Company D.

I'd like to store this relationship in the DB. However after this data has been stored in the DB, I'd also like to be able to use this data to now show from Company B's perspective, that they are competing with Company A and are likely to be competing with Company C and Company D.

How best to achieve this functionality? What is the best way to store this kind of relationship in EF Core?

Should it be a many-to-many relationship? If the table looks something like this:

---------------------------
| Company   | Competitors |
 --------------------------
| CompanyA  | Company B   |
| CompanyA  | Company C   |
| CompanyA  | Company D   |
---------------------------

Wouldn't I need to have some kind of a 'cyclical/nested' loading when I want to display competitors from Company B's perspective in EF Core? Ie. I would first need to load the relationship of B to A and then A to all the others.

Is this the most optimum way to store such a relationship or is there a better way?

Stack64325
  • 43
  • 4
  • What is your 1 specific researched non-duplicate question re how you are 1st stuck on what part of the whole? [ask] [Help] PS [Are There Bidirectional Relational Databases?](https://stackoverflow.com/a/40329503/3404097) – philipxy Aug 22 '22 at 11:43

0 Answers0