Relation attribute linked to a node

Viewed 33

I want to have a schema where a user can give a vote to another user, for a specific theme.

I wonder the best way to doing this.

  • The first way I think of is to make a relation between users with an attribute 'theme'.
(a)-[r:GIVE_VOTE {theme: "theme"}]->(b)
  • The second one is to have a Delegation node, which have an "input" relation to the user who have given his vote, an 'output' relation to the user who received the vote, and another to a node "theme".
CREATE (:Person)-[:GIVE_VOTE]->(d:Delegation)-[:GIVE_VOTE]->(:Person)
CREATE (d)-[:FOR_THEME]->(:Theme)

For a huge number of nodes, have one string "theme" for each relation can be really heavy, but having a node Delegation with 3 relation, and a node "theme" too ... .

Maybe someone have a different way to do it, or an opinion on the two ways I can think of ?

1 Answers

This is how we resolved an issue on "heavy" relationship for node (we call it densed node).

Instead of 
(a)-[r:GIVE_VOTE {theme: "theme"}]->(b),
We do this
(a)-[r:GIVE_VOTE_<theme>]->(b)

It is faster to query on a relationship with this setting rather than searching at the attribute r.theme.

Related