What is the proper case for using the Property attribute of a Relationship in Neo4j? (Including examples of when and when not to use them)
Consider a computer used by Team A and Team B, where each team have their own internal value id for the computer:
Node = Team : properties = {'name'='Team A'}
^
|
Relationship = "Used By..."
|
Node = Computer : properties = {'Type':'MacBook', 'CPU':'i7', 'id'='TeamA1-MBKi7'}
If Team B has the same relationship but with a different value for id:
Would it be correct to move the property id out of the Computer node and into a 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 your specific example, you could add a new Model node label to describe a type of computer, as in:
(:Team {name: 'Team A'})<-[:USED_BY]-(:Computer {id: 'TeamA1-MBKi7'})-[:IS_A]->(:Model {type:'MacBook', cpu:'i7'})
That will allow multiple Computer nodes to share the same model information.
To address your more general question, here are some thoughts:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With