
There may be many reasons to use DBMS, but the primary reason might be for efficiently storing and retrieving data. To achieve ease of data retrieval and manipulation, existing RDBMSs support SQL. You can create, read, update, and delete data in RDBMSs through standardized way.
What about graph databases?
There are several graph databases out there and they offer their own query language to achieve the same goal. There is no standardized way in the graph world. In this posting, we will briefly introduce query languages that are supported by existing graph databases. The list of graph databases that are introduced in this posting is as follows.
- Neo4j
- OrientDB
- Titan
- ArangoDB
Let’s learn each query language briefly through a simple example user query “Find persons who are friend-of-friend of J.”
1. Neo4j
Neo4j offers Cypher, a declarative query language. It is optimized for reading because it nearly draws graph patterns with some keywords to create and read graphs. Here is the Cypher query to run the above example user query.
MATCH (:Person {name: ‘J’})-[:FRIEND*2]->(f:Person)
RETURN f.name
You can easily find out what the relathioship the query uses, how many relationships it follows, and more.
See also Cypher Query Language for more details.
2. OrientDB
OrientDB offers OrientDB SQL which is based on SQL but few are different. Some extensions are added to the query language to enable graph functionality. So, graph pattern matching queries can be written in a declarative fashion. Below is the OrientDB SQL query to run the above example user query.
SELECT f.name FROM (
MATCH
{class: Person, where: (name = ‘J’)}
.out(‘FRIEND’)
{class: Person, as: f, while: ($depth 1)}
RETURN f)
The above query is not as intuitive as the same query written in Cypher, but it is pretty readable.
See also Match for more details.
3. Titan
Titan offers Gremlin which is developed by Apache TinkerPop. In Gremlin, a graph traversal is composed of an ordered list of steps. And it supports declarative graph pattern matching through match()-step. Here is the Gremlin query to run the above example user query.
g.V().match(
__.hasLabel(‘Person’).has(‘name’, ‘J’).
repeat(out(‘FRIEND’)).times(2).
hasLabel(‘Person’).as(‘f’)
).select(‘f’).values(‘name’)
The above query looks like codes written in functional languages and also is somewhat similar to Cypher.
See also Match Step for more details.
4. ArangoDB
ArangoDB offers AQL. It is also a declarative language like others and is similar to SQL but the syntax is different. Below is the AQL query to run the above example user query.
FOR n IN person
FILTER n.name == ‘J’
LET name = (FOR f, e IN 2..2 OUTBOUND n._id friend
FILTER IS_SAME_COLLECTION(‘person’, f._id)
RETURN f.name)
RETURN {name: name}
See also Graph Traversals in AQL for more details.
Conclusion
We’ve looked simple use of four graph query languages. Although it is not enough to grasp the power of each language, this posting might be a good start point. Because each language has different pros and cons from each other, see the documentations linked above for more detailed information.
About this page
Last reviewed October 30, 2026 by the Nine Bits editors. Read our editorial policy or report an error.