Databases Reference
In-Depth Information
algorithms, adding additional semantics to relationships (including quality and
weight), and for constraining queries at runtime.
These simple primitives are all we need to create sophisticated and semantically rich
models. So far, all our models have been in the form of diagrams. Diagrams are great
for describing graphs outside of any technology context, but when it comes to using a
database, we need some other mechanism for creating, manipulating, and querying
data. We need a query language.
Querying Graphs: An Introduction to Cypher
Cypher is an expressive (yet compact) graph database query language. Although specific
to Neo4j, its close affinity with our habit of representing graphs using diagrams makes
it ideal for programatically describing graphs in a precise fashion. For this reason, we
use Cypher throughout the rest of this topic to illustrate graph queries and graph con‐
structions. Cypher is arguably the easiest graph query language to learn, and is a great
basis for learning about graphs. Once you understand Cypher, it becomes very easy to
branch out and learn other graph query languages. 1
In the following sections we'll take a brief tour through Cypher. This isn't a reference
document for Cypher, however—merely a friendly introduction so that we can explore
more interesting graph query scenarios later on. 2
Other Query Languages
Other graph databases have other means of querying data. Many, including Neo4j, sup‐
port the RDF query language SPARQL and the imperative, path-based query language
Gremlin . Our interest, however, is in the expressive power of a property graph combined
with a declarative query language, and so in this topic we focus almost exclusively on
Cypher.
Cypher Philosophy
Cypher is designed to be easily read and understood by developers, database profes‐
sionals, and business stakeholders. Its ease of use derives from the fact it accords with
the way we intuitively describe graphs using diagrams.
1. The Cypher examples in the topic were written using Neo4j 2.0. Most of the examples will work with versions
1.8 and 1.9 of Neo4j. Where a particular language feature requires the latest version, we'll point it out.
2. For reference documentation see http://bit.ly/15Fjjo1 and http://bit.ly/17l69Mv .
 
Search WWH ::




Custom Search