Neo4j Design: When to use Properties for Relationships -
what proper case using property attribute of relationship in neo4j? (including examples of when , when not use them)
example
consider computer used team a
, team b
, each team have own internal value id
computer:
node = team : properties = {'name'='team a'} ^ | relationship = "used by..." | node = computer : properties = {'type':'macbook', 'cpu':'i7', 'id'='teama1-mbki7'}
if team b
has same relationship different value id
:
would correct move property id
out of computer
node , relationship property?
e.g.
node = team : properties = {'name'='team a'} ^ | relationship = "used by..." : properties = {'id'='teama1-mbki7'} | node = computer : properties = {'type':'macbook', 'cpu':'i7'}
to address specific example, add new model
node label describe type of computer, in:
(:team {name: 'team a'})<-[:used_by]-(:computer {id: 'teama1-mbki7'})-[:is_a]->(:model {type:'macbook', cpu:'i7'})
that allow multiple computer
nodes share same model information.
to address more general question, here thoughts:
- neo4j not allow create index or uniqueness constraint on relationship. (remember, nodes: index or uniqueness constraint associated node label , node property.) therefore, if wanted (or might want to) create index or uniqueness constraint involving property, should put in node.
- a relationship can used once, make single connection between 2 nodes. if wanted (or might ever want to) involve same property value in multiple connections, should consider putting in node.
- if property relevant specific pair of nodes (and not relevant 1 of nodes), should relationship property.
Comments
Post a Comment