Skip to content

Instantly share code, notes, and snippets.

@technige
Last active April 1, 2020 09:57
Show Gist options
  • Save technige/9366313 to your computer and use it in GitHub Desktop.
Save technige/9366313 to your computer and use it in GitHub Desktop.
The Zen of Cypher

The Zen of Cypher

  • Write functions() in lower case, KEYWORDS in upper.
  • START each keyword clause
    ON a new line.
  • Use either camelCase or snake_case for node identifiers but be consistent.
  • Relationship type names should use UPPER_CASE_AND_UNDERSCORES.
  • Label names should use CamelCaseWithInitialCaps.
  • MATCH (clauses)-->(should)-->(always)-->(use)-->(parentheses)-->(around)-->(nodes)
  • Backticks `cân éscape odd-ch@racter$ & keyw0rd$` but should be a code smell.
  • Don't put (extra) --> (whitespace) - [:IN] -> (patterns)
  • Except for (line)-->
    (breaks)
  • If you want to wrap patterns across multiple lines, break (after)-->
    (arrows) but (not)
    -->(before)
  • Try to chain patterns together (instead)-[:OF]->(repeating),
    (repeating)-->(nodes)
  • (right)<-[:TO]-(left)<-[:FROM]-(patterns)<--(write)<-[:TO]-(try)
@jotomo
Copy link

jotomo commented Mar 11, 2014

Neat :-)
I got one nitpick though: the always use parentheses around node identifiers should probably be extended with when matching. I fancied using parentheses on all node identifiers - for consistency mostly, but that doesn't work when SETing a label, e.g. MATCH (n:Labbel) SET (n:ProperLabel) will not work, the node identifier must not have parenthesis in that case. I'm wondering though whether it should be that way ...

@technige
Copy link
Author

Great point, I have updated to reflect that :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment