
Cypher
Cypher is a query language for graph databases that lets you search and analyze relationships between data points in a targeted way. It was originally developed for the Neo4j database and is now an open standard.
Cypher is a language used to query data from a graph database. A graph database doesn’t store information in tables, but as a network of nodes and connections — similar to a mind map. Cypher allows you to search this network: Who knows whom? Which products did customers buy who also bought product X? The language was developed by the company Neo4j and released in 2015 as an open standard under the name openCypher.
Why graph databases need their own language
The best-known database language is called SQL and is made for tables. A table stores rows and columns — for example, a customer list. Relationships between tables can be represented, but quickly become unwieldy. If you want to know who the friends of the friends of the friends of a person are, SQL needs several nested queries for that. The deeper the chain of connections, the slower it gets.
Graph databases are built precisely for such chains of connections. Cypher exploits this strength. A query that would take ten lines in SQL can often be written in two in Cypher. This is no coincidence — Cypher was designed from the start to put relationships between data points at the center, not the data points themselves.
How Cypher describes relationships
What’s special about Cypher is its visual syntax. Nodes are written in round brackets, connections as arrows between these brackets. A query like `(alice)-[:KNOWS]->(bob)` means: Find all cases in which a person named Alice knows someone named Bob. You read the statement almost the way you would draw it on paper.
With the keyword MATCH you search for patterns in the graph, with RETURN you specify what should be returned. A complete query could read: `MATCH (p:Person)-[:BOUGHT]->(p2:Product) WHERE p2.name = 'Headphones' RETURN p.name` — in other words: Give me the names of all people who bought headphones. Other keywords such as WHERE, CREATE, or DELETE allow you to filter, add, or delete data.
A common misconception: Cypher is not a programming language. You cannot write algorithms or build loops with it. Cypher only describes which data you want — how it’s retrieved is decided by the database.
Where Cypher is used today
Cypher shows up wherever connections between data points matter more than the data points themselves. Social networks like LinkedIn use graph databases to calculate second- and third-degree contacts. Banks use them for fraud detection: If three different accounts share the same phone number, that’s a warning sign — a pattern Cypher can find in milliseconds.
Cypher is also gaining importance in the AI world. So-called knowledge graphs store structured knowledge as a network. Search engines like Google use such graphs to understand that “Angela Merkel” is a person who served as Chancellor of Germany from 2005 to 2021. Cypher is one of the languages used to query these graphs.
Since openCypher became available as an open standard in 2015, other databases have adopted the language, including Amazon Neptune and Redis. In 2023, Cypher even became part of an ISO standard for graph query languages. The language is thus no longer purely a Neo4j tool, but a general standard — similar to how SQL is for table-based databases.