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:

  1. 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.
  2. 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.
  3. if property relevant specific pair of nodes (and not relevant 1 of nodes), should relationship property.

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -