Graph database (GDB)
A graph database stores data as nodes and the relationships between them, so that connected information, such as who knows whom or which part goes into which product, can be stored and queried directly.
A relational database keeps data in tables of rows and columns, linked by shared keys. A graph database instead stores nodes (things, such as people, accounts or products), edges (the relationships between them, such as KNOWS, PAID or CONTAINS) and properties (details attached to either). Relationships are stored as data in their own right, with a direction and their own properties, rather than being worked out at query time.
There are two main models. In a labelled property graph, both nodes and relationships carry key-value properties and nodes can be grouped by labels. The RDF model, standardised by the W3C, stores every fact as a subject, predicate and object, so adding a person's name means adding another link rather than a property.
The advantage shows in questions that follow chains of connections: friends of friends, the path money took through a series of accounts, every component affected by a faulty part. A relational database answers these with repeated joins, which get expensive as the chain lengthens. Many graph databases use index-free adjacency, where each node points directly at its neighbours, so the cost of a query depends on the part of the graph it explores rather than the size of the whole database. For bulk operations over many records, relational databases are usually faster, and switching only for the data model is rarely worth it.
No single query language has won. Cypher (from Neo4j), Gremlin (from Apache TinkerPop) and SPARQL (the W3C language for RDF) are all widely used. On April 12, 2024 ISO and IEC published GQL, ISO/IEC 39075, a standard query language for property graphs that grew out of proposals from Neo4j and Oracle. Products include Neo4j, Amazon Neptune, TigerGraph, ArangoDB and JanusGraph.
Graph databases have gained attention in AI because they are a natural home for knowledge graphs. In April 2024 Darren Edge and colleagues described GraphRAG, which uses a language model to extract a graph of entities from documents and summarises groups of related entities so that a system can answer broad questions about a whole collection. A graph database does not make an AI system accurate by itself; it makes relationships explicit, which is useful only if those relationships are right.
It is used where the connections between things matter as much as the things themselves: social networks, recommendations based on what people buy or like, mobile and Internet of Things data, and knowledge graphs. It suits queries that follow many links. A relational database stores data in tables and reconstructs relationships at query time with joins. A graph database stores relationships directly as edges between nodes, which makes multi-step connection queries faster, while relational databases are usually better for bulk operations on large sets of records. GQL is the ISO/IEC 39075 standard query language for property graphs, published on April 12, 2024. It is meant to play a role for graph databases similar to the one SQL plays for relational databases, and it grew out of proposals from Neo4j and Oracle. No. A graph database is software for storing and querying graph-shaped data. A knowledge graph is a body of facts about entities and their relationships, often with rules describing what they mean. Knowledge graphs are often stored in graph databases, but can be stored in other ways.Common questions
What is a graph database used for?
What is the difference between a graph database and a relational database?
What is GQL?
Is a graph database the same as a knowledge graph?
Search for "graph database", "property graph vs RDF", "Cypher query language" or "ISO GQL". Vendor documentation explains how individual products work, and standards bodies such as ISO and the W3C define the query languages. Treat performance comparisons from database vendors with care, since they tend to choose workloads that suit their own systems.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.