Swordfish
Swordfish

Reputation: 1281

Neo4j modeling relationship query

I have a query regarding modeling a relationship in Neo4j:

Here is a graph that I am creating:

enter image description here

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

Answers (1)

Graphileon
Graphileon

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).

Graph model

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.

Graph model 2

Upvotes: 1

Related Questions