Introduction
Graph Query Language (GQL) standard was published in 2024. The standard formalizes pattern matching which the workhorse of graph query languages. This pattern matching is represented as ASCII-art like syntax. At a high level, when evaluating a query, GQL keeps track of three things:- the working graph, which is the property graph we are using to match our patterns currently;
- the working table, that stores the information computed thus far; and
- the working record, which contains the tuple of the result we are currently using.
(a)-[:links_to]->{m,n}(b) selects all nodes b that are reachable from a by following one or more edges in the graph, traversing the graph using the :links_to relation. Recursive queries compute the transitive closure of the graph, and return the nodes in the graph that can be reached starting from a given one.
Graph Databases
Graph databases are a class of database management systems that store data as nodes (entities) and edges (relationships) rather than in rows and columns. Graph databases differ from relational databases in three architecturally significant ways:- Index-free adjacency: each node physically stores direct pointers to its adjacent nodes, so traversing a relationship is an O(1) pointer dereference, not an O(log N) index lookup or O(N) table scan as in relational systems.
- Labelled property graphs: nodes and edges carry labels (types) and key-value properties, enabling a single data structure to represent both the topology of relationships and the quantitative and qualitative attributes needed for statistical computation.
- Native graph query languages (such as Cypher, GQL, or Gremlin) express multi-hop traversal patterns declaratively, making complex relationship queries concise and efficient.