GQL learning guide · Dominik Tomaszuk
GQL vs SQL: Graph Patterns and Relational Joins
SQL queries tables; GQL queries property graphs. Both can return tabular results, filter rows and aggregate values. The difference is visible when a query follows connections between entities.
The same question in two models
Suppose we need book titles for a particular loan. In a graph, an INCLUDES edge links the loan directly to each book:
MATCH (l:Loan)-[:INCLUDES]->(b:Book)
WHERE l.loanid = 'L-2025-0001'
RETURN b.title AS titleA relational design could store loans, books and an association table. With tables loans(loanid), books(isbn, title) and loan_books(loanid, isbn), the equivalent question uses joins:
SELECT b.title AS title
FROM loans AS l
JOIN loan_books AS lb ON lb.loanid = l.loanid
JOIN books AS b ON b.isbn = lb.isbn
WHERE l.loanid = 'L-2025-0001'The correspondence assumes that these tables encode the same connections as the graph and that the identifiers are unique. Duplicate association rows or different constraints can change result multiplicity.
Where does relationship data live?
A due date for a borrowed book belongs on the graph's INCLUDES edge. In the relational design, it belongs in loan_books. The models can represent the same facts, while their query notation exposes those facts differently.
Patterns still produce rows
Matching a graph does not imply returning a single graph object. A GQL pattern binds variables into rows, which later operations can filter, combine or aggregate. SQL experience with joins and grouping is useful, but graph path modes and matching rules need separate attention.
Choosing an approach
A relationship-heavy question may be easier to express as a graph pattern. A table-oriented workload may fit an existing relational schema well. Query length alone does not establish performance; the data, indexes and execution engine determine the cost.
Read the book's comparison with SQL and other languages, then study binding-table algebra and path semantics for the formal differences.
Learn GQL
Start with a short guide, then follow links to the relevant chapters.