I'm curious about naming conventions in neo4j.
I noticed in their examples that relationship names where capitalized, e.g.
left-[r:KNOWS]->right
Is that the convention? Is neo4j case sensitive in relationship names? Are there other naming conventions around index names and property names?
Label is a name or identifier to a Node or a Relationship in Neo4j Database. We can say this Label name to a Relationship as "Relationship Type". We can use CQL CREATE command to create a single label to a Node or a Relationship and multiple labels to a Node.
You cannot rename an already existing relationship. You'd have to run through all relationships, create the new one in parallel (including all properties) and then remove the old one.
Properties are key-value pairs that are used for storing data on nodes and relationships. The value part of a property: Can hold different data types, such as number , string , or boolean .
That is the convention. I personally use lower case relationship types, and yes, it is case-sensitive. With underscores.
Usually, people use underscores for index names as well, and they're usually lower case, and also case-sensitive.
Also, something to remember: if you don't specify direction while creating, the default is left<--right. Not intuitive for me, but now I just specify direction always.
For the properties, I think most people use JSON style conventions: http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml#Key_Names_in_JSON_Maps
I've also seen underscores for properties, so I guess it goes either way. Just be consistent!
Yes, the convention for relationship names is to have them ALL_UPPERCASE. All names in Neo4j are case-sensitive (labels, relationships, properties, ...)
Keep in mind that this is a convention, not a requirement. The most important part in any project is consistency. Use a coding style and stick to it throughout!
Neo4j naming convention:
Cypher examples:
CREATE (:Person {name:"Anne"})-[:MANAGES {start_date:20121112}]->(:WorkGroup {name:"Dev"});
Alternatively:
CREATE (:Person {name:"Anne"})-[:MANAGES {startDate:20121112}]->(:WorkGroup {name:"Dev"});
References:
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