Cypher is like SQL a declarative, textual query language, but for graphs.
It consists of clauses, keywords and expressions like predicates and functions, many of which will be familiar (like WHERE
, ORDER BY
, SKIP LIMIT
, AND
, p.unitPrice > 10
).
Unlike SQL, Cypher is all about expressing graph patterns.
We added a special clause MATCH
for matching those patterns in your data.
These patterns are what you would usually draw on a whiteboard, just converted into text using ASCII-art symbols.
We represent the circles of node entities with round parentheses, like this: (p:Product)
.
And arrows of relationships are drawn as such -->
, you can add relationship-type and other information in square brackets
-[:ORDERED]->
.
Bringing both together ()-->()<--()
looks almost like our original diagram.
It gives us a first hint at the expressiveness of graph patterns: (cust:Customer)-[:ISSUED]->(o:Order)-[:CONTAINS]->(prod:Product)
.
Other highlights of Cypher are graph concepts like paths, variable length paths, shortest-path functions; the support of many functions, operations and predicates on lists and the ability to chain query parts.
You can use Cypher to update the graph structure and data and even ingest large amounts of CSV data.
With user defined procedures you can extend the language with functionality that you need but which is currently not yet available.
With the openCypher project, Cypher became an open effort for a modern graph query language, that is supported by several database companies. The openCypher project also provides syntax diagrams that you’re used to from SQL:
This is a companion discussion topic for the original entry at https://neo4j.com/developer/cypher/guide-sql-to-cypher/