Reputation: 1281
I have a query regarding modeling a relationship in Neo4j:
Here is a graph that I am creating:
If I wanted to specify which products company2 is competing with company1 e.g. just product A. Would I have to put a list of products on the COMPETES relationship? or is there another way?
Upvotes: 0
Views: 74
Reputation: 5385
I think the definition of 'competing' should be more explicit. From the diagram you post, my common sense is that they compete on A and B, because they are both offering these products.
Putting an array of product(ids) on the COMPETES rel could work, but is not very 'graphy'
I would add (:Competition) nodes, and link them to each of the competing companies, as well as to specific products. The advantage would be that you can use this node, or the rel to store data on the type of competition (price, quality).
Another approach (perhaps even better) would be to create :(:Offering) nodes between the company and the products, and create [:COMPETES] rels between the competing offerings.
Upvotes: 1