Cypher is a declarative pattern matching language created by Neo4j for the purposes of describing graph data representations effectively. Cypher is considered to be one of the most powerful features fore effectively expressing graph database traversals for reading and writing graph database data into Neo4j.
Cypher makes it capable for queries to do something like: “bring back my friends’ friends right now” or “give me back all pages this page is linked to within the last day” in the form of several code lines. As such, graph database queries and operations across all languages and integrations with Neo4j are able to query in a consistent manner.
The reception to Cypher has been so great that Neo4j launched the OpenCypher initiative to make Cypher the SQL for graph databases. The organizations that are joining OpenCypher are very important to the graph database movement because supporting a common graph database query language means there will be more utilization and commonality across graph database implementations.
If we want to find all people and their preferences, the query will involve identifiers for the person and thing. A pattern like “(person)-[:LIKES]->(thing)” could be utilized so it can be referred to later say, for instance, to gain access to properties such as “person.name” and “thing.title.”
Writing and representing depth based queries is one place where cypher makes it really easy to do. To look at my friends of friends is as simple as “(me)-[:FRIEND*2]->(fof). It’s actually fun to create queries because its comprehensive nature follows direct patterns and relationships without having to think about what needs joining together to aggregate the required data.
If you dig deeper into the workings of the Neo4j native graph database and computer systems on which it runs, you’ll find that Neo4j is a highly optimized product that is very system-friendly.
With Neo4j, nodes and relationship are housed in divided files. Every node is housed as a “constant length” record with a pointer to its initial property and initial relationship. And every relationship is also stored as a constant length with a pointer to its last and next relationship. Such constant length record promotes for a faster look-up.
Layering Cypher on top of any graph database from organizations that join the OpenCypher movement will be an advantage for representing the graph database models, but layering on a native graph database, like Neo4j, will provide an even greater advantage thanks to completely natural pairing of native graph database storage and a native graph database query language like Cypher.