Graph database

In computing, a graph database is a database that uses graph structures for semantic queries with nodes, edges, and properties to represent and store data. A key concept of the system is the graph. The graph relates the data items in the store to a collection of nodes and edges, the edges representing the relationships between the nodes. The relationships allow data in the store to be linked together directly and, in many cases, retrieved with one operation. Graph databases hold the relationships between data as a priority. Querying relationships is fast because they are perpetually stored in the database. Relationships can be intuitively visualized using graph databases, making them useful for heavily inter-connected data.
Graph databases are a type of NoSQL database, created to address the limitations of relational databases. While the graph model explicitly lays out the dependencies between nodes of data, the relational model and other NoSQL database models link the data by implicit connections. Graph databases, by design, allow simple and fast retrieval of complex hierarchical structures that are difficult to model in relational systems. Graph databases are similar to 1970s network model databases in that both represent general graphs, but network-model databases operate at a lower level of abstraction and lack easy traversal over a chain of edges.
The underlying storage mechanism of graph databases can vary. Some depend on a relational engine and “store” the graph data in a table. Others use a key-value store or document-oriented database for storage, making them inherently NoSQL structures. Most graph databases based on non-relational storage engines also add the concept of tags or properties, which are essentially relationships having a pointer to another document. This allows data elements to be categorized for easy retrieval en masse.
Retrieving data from a graph database requires a query language other than SQL, which was designed for the manipulation of data in a relational system and therefore cannot "elegantly" handle traversing a graph., no universal graph query language has been adopted in the same way as SQL was for relational databases, and there are a wide variety of systems, most often tightly tied to one product. Some standardization efforts have occurred, leading to multi-vendor query languages like Gremlin, SPARQL, and Cypher. In addition to having query language interfaces, some graph databases are accessed through application programming interfaces.
Graph databases differ from graph compute engines. Graph databases are technologies that are translations of the relational online transaction processing databases. On the other hand, graph compute engines are used in online analytical processing for bulk analysis. Graph databases attracted considerable attention in the 2000s, due to the successes of major technology corporations in using proprietary graph databases, and the introduction of open-source graph databases.


In the mid-1960s, navigational databases such as IBM's IMS supported tree-like structures in its hierarchical model, but the strict tree structure could be circumvented with virtual records.
Graph structures could be represented in network model databases from the late 1960s. CODASYL, which had defined COBOL in 1959, defined the Network Database Language in 1969.
Labeled graphs could be represented in graph databases from the mid-1980s, such as the Logical Data Model.
Several improvements to graph databases appeared in the early 1990s, accelerating in the late 1990s with endeavors to index web pages.
In the mid-to-late 2000s, commercial graph databases with ACID guarantees such as Neo4j and Oracle Spatial and Graph became available.
In the 2010s, commercial ACID graph databases that could be scaled horizontally became available. Further, SAP HANA brought in-memory and columnar technologies to graph databases. Also in the 2010s, multi-model databases that supported graph models became available, such as OrientDB, ArangoDB, and MarkLogic. During this time, graph databases of various types have become especially popular with social network analysis with the advent of social media companies.


Graph databases portray the data as it is viewed conceptually. This is accomplished by transferring the data into nodes and its relationships into edges.
A graph database is a database that is based on graph theory. It consists of a set of objects, which can be a node or an edge.

Labeled-property graph

A labeled-property graph model is represented by a set of nodes, relationships, properties, and labels. Both nodes of data and their relationships are named and can store properties represented by key/value pairs. Nodes can be labelled to be grouped. The edges representing the relationships have two qualities: they always have a start node and an end node, and are directed; making the graph a directed graph. Relationships can also have properties. This is useful in providing additional metadata and semantics to relationships of the nodes. Direct storage of relationships allows a constant-time traversal.

Resource Description Framework (RDF)

In an RDF graph model, the addition of information is each represented with a separate node. For example, imagine a scenario where a user has to add a name property for a person represented as a distinct node in the graph. In a labeled-property graph model, this would be done with an addition of a name property into the node of the person. However, in an RDF, the user has to add a separate node called hasName connecting it to the original person node. Specifically, an RDF graph model is composed of nodes and arcs. An RDF graph notation or a statement is represented by: a node for the subject, a node for the object, and an arc for the predicate. A node may be left blank, a literal and/or be identified by a URI. An arc may also be identified by a URI. A literal for a node may be of two types: plain and typed. A plain literal has a lexical form and optionally a language tag. A typed literal is made up of a string with a URI that identifies a particular datatype. A blank node may be used to accurately illustrate the state of the data when the data does not have a URI.
It is used in Facebook's Open Graph protocol to "allow any web page to have the same functionality as any other object on Facebook" and the Semantic Web.


Graph databases are a powerful tool for graph-like queries. For example, computing the shortest path between two nodes in the graph. Other graph-like queries can be performed over a graph database in a natural way.
Graphs are flexible, meaning it allows the user to insert new data into the existing graph without loss of application functionality. There is no need for the designer of the database to plan out extensive details of the database's future use cases.


The underlying storage mechanism of graph databases can vary. Some depend on a relational engine and “store” the graph data in a table. Others use a key-value store or document-oriented database for storage, making them inherently NoSQL structures. One such NoSQL database that utilizes this method is ArangoDB. ArangoDB is a native multi-model database that supports graphs as one of its data models. It stores graphs by holding edges and nodes in separate collections of documents. A node would be represented as any other document store, but edges that link two different nodes hold special attributes inside its document; a _from and _to attributes.

Index-free adjacency

Data lookup performance is dependent on the access speed from one particular node to another. Because index-free adjacency enforces the nodes to have direct physical RAM addresses and physically point to other adjacent nodes, it results in a fast retrieval. A native graph system with index-free adjacency does not have to move through any other type of data structures to find links between the nodes. Directly related nodes in a graph are stored in the cache once one of the nodes are retrieved, making the data lookup even faster than the first time a user fetches a node. However, such advantage comes at a cost. index-free adjacency sacrifices the efficiency of queries that do not use graph traversals. Native graph databases use index-free adjacency to process CRUD operations on the stored data.

Graph types

There are multiple types of graphs that can be categorized. Gartner suggests the five broad categories of graphs:
Since Edgar F. Codd's 1970 paper on the relational model, relational databases have been the de facto industry standard for large-scale data storage systems. However, relational models require a strict schema and data normalization imposed limitations on how relationships can be queried. The increasing amount of data needing to be processed became an additional problem posed by the relational model.
Traditionally, databases have been designed with the relational model, where data is normalized to support ACID transactions. The data normalization process removes any duplicate data within the database. The goal of data normalization is to preserve data consistency. The relational model enforces ACID transactions, separating data into many tables.
Relational models enforce heavy data normalization in order to guarantee consistency. One of the relational model's design motivations was to achieve a fast row-by-row access. Problems arise with when there is a need to form complex relationships between the stored data. Although relationships can be analyzed with the relational model, complex queries performing many join operations on many different attributes over several tables are required. In working with relational models, foreign key constraints should also be considered when retrieving relationships, causing additional overhead.
Compared with relational databases, graph databases are often faster for associative data sets and map more directly to the structure of object-oriented applications. They can scale more naturally to large datasets as they do not typically need join operations, which can often be expensive. As they depend less on a rigid schema, they are marketed as more suitable to manage ad hoc and changing data with evolving schemas.
Conversely, relational database management systems are typically faster at performing the same operation on large numbers of data elements, permitting the manipulation of the data in its natural structure. Despite the graph databases' advantages and recent popularity over the relational databases, it is recommended the graph model itself should not be the sole reason to replace an existing relational database. A graph database may become relevant if there is an evidence for performance improvement by orders of magnitude and lower latency.


The relational model gathers data together using information in the data. For example, one might look for all the "users" whose phone number contains the area code "311". This would be done by searching selected datastores, or tables, looking in the selected phone number fields for the string "311". This can be a time-consuming process in large tables, so relational databases offer indexes, which allow data to be stored in a smaller sub-table, containing only the selected data and a unique key of the record. If the phone numbers are indexed, the same search would occur in the smaller index table, gathering the keys of matching records, and then looking in the main data table for the records with those keys. Usually, a table is stored in a way that allows a lookup via a key to be very fast.
Relational databases do not inherently contain the idea of fixed relationships between records. Instead, related data is linked to each other by storing one record's unique key in another record's data. For example, a table containing email addresses for users might hold a data item called userpk, which contains the primary key of the user record it is associated with. In order to link users and their email addresses, the system first looks up the selected user records primary keys, looks for those keys in the userpk column in the email table, extracts the email data, and then links the user and email records to make composite records containing all the selected data. This operation, termed a join, can be computationally expensive. Depending on the complexity of the query, the number of joins, and indexing various keys, the system may have to search through multiple tables and indexes and then sort it all to match it together.
In contrast, graph databases directly store the relationships between records. Instead of an email address being found by looking up its user's key in the userpk column, the user record contains a pointer that directly refers to the email address record. That is, having selected a user, the pointer can be followed directly to the email records, there is no need to search the email table to find the matching records. This can eliminate the costly join operations. For example, if one searches for all of the email addresses for users in area code "311", the engine would first perform a conventional search to find the users in "311", but then retrieve the email addresses by following the links found in those records. A relational database would first find all the users in "311", extract a list of the primary keys, perform another search for any records in the email table with those primary keys, and link the matching records together. For these types of common operations, graph databases would theoretically be faster.
The true value of the graph approach becomes evident when one performs searches that are more than one level deep. For example, consider a search for users who have "subscribers" in the "311" area code. In this case a relational database has to first search for all the users with an area code in "311", then search the subscribers table for any of those users, and then finally search the users table to retrieve the matching users. In contrast, a graph database would search for all the users in "311", then follow the backlinks through the subscriber relationship to find the subscriber users. This avoids several searches, look-ups, and the memory usage involved in holding all of the temporary data from multiple records needed to construct the output. In terms of big O notation, this query would be time – i.e., proportional to the logarithm of the size of the data. In contrast, the relational version would be multiple lookups, plus the time needed to join all of the data records.
The relative advantage of graph retrieval grows with the complexity of a query. For example, one might want to know "that movie about submarines with the actor who was in that movie with that other actor that played the lead in Gone With the Wind". This first requires the system to find the actors in Gone With the Wind, find all the movies they were in, find all the actors in all of those movies who were not the lead in Gone With the Wind, and then find all of the movies they were in, finally filtering that list to those with descriptions containing "submarine". In a relational database, this would require several separate searches through the movies and actors tables, doing another search on submarine movies, finding all the actors in those movies, and then comparing the collected results. In contrast, the graph database would walk from Gone With the Wind to Clark Gable, gather the links to the movies he has been in, gather the links out of those movies to other actors, and then follow the links out of those actors back to the list of movies. The resulting list of movies can then be searched for "submarine". All of this can be done via one search.
Properties add another layer of abstraction to this structure that also improves many common queries. Properties are essentially labels that can be applied to any record, or in some cases, edges as well. For example, one might label Clark Gable as "actor", which would then allow the system to quickly find all the records that are actors, as opposed to director or camera operator. If labels on edges are allowed, one could also label the relationship between Gone With the Wind and Clark Gable as "lead", and by performing a search on people that are "lead" "actor" in the movie Gone With the Wind, the database would produce Vivien Leigh, Olivia de Havilland and Clark Gable. The equivalent SQL query would have to rely on added data in the table linking people and movies, adding more complexity to the query syntax. These sorts of labels may improve search performance under certain circumstances, but are generally more useful in providing added semantic data for end users.
Relational databases are very well suited to flat data layouts, where relationships between data is one or two levels deep. For example, an accounting database might need to look up all the line items for all the invoices for a given customer, a three-join query. Graph databases are aimed at datasets that contain many more links. They are especially well suited to social networking systems, where the "friends" relationship is essentially unbounded. These properties make graph databases naturally suited to types of searches that are increasingly common in online systems, and in big data environments. For this reason, graph databases are becoming very popular for large online systems like Facebook, Google, Twitter, and similar systems with deep links between records.
To further illustrate, imagine a relational model with two tables: a people table and a friend table. In this case, searching for all of Jack's friends would result in the following SQL query.

SELECT p2.person_name
FROM people p1
JOIN friend ON
JOIN people p2 ON
WHERE p1.person_name = 'Jack';

The same query may be translated into --
WHERE = "Jack"

PREFIX foaf:
SELECT ?name

  • * Short form
PREFIX foaf:
SELECT ?name

  • SPASQL, a hybrid database query language, that extends SQL with SPARQL
FROM AS people ;

The above examples are a simple illustration of a basic relationship query. They condense the idea of relational models' query complexity that increases with the total amount of data. In comparison, a graph database query is easily able to sort through the relationship graph to present the results.
There are also results that indicate simple, condensed, and declarative queries of the graph databases do not necessarily provide good performance in comparison to the relational databases. While graph databases offer an intuitive representation of data, relational databases offer better results when set operations are needed.

List of graph databases

The following is a list of graph databases:
AllegroGraph7.0.0 C#, C, Common Lisp, Java, PythonResource Description Framework and graph database
Amazon Neptune1. Not disclosedAmazon Neptune is a fully managed graph database by It is used as a web service and is part of Amazon Web Services. Supports popular graph models property graph and W3C's RDF, and their respective query languages Apache TinkerPop Gremlin and SPARQL.
AnzoGraph DB2.1 C, C++AnzoGraph DB is a massively parallel native graph GOLAP style database built to support SPARQL and Cypher Query Language to analyze trillions of relationships. AnzoGraph DB is designed for interactive analysis of large sets of semantic triple data, but also supports labeled properties under proposed W3C standards.
ArangoDB3.3.11 / ,C++, JavaScript,.NET, Java, Python, Node.js, PHP, Scala, Go, Ruby, ElixirNoSQL native multi-model database system developed by ArangoDB Inc. The database system supports three important data models with one database core and a unified query language called AQL
DataStax Enterprise Graphv6.0.1 JavaDistributed, real-time, scalable database; supports Tinkerpop and integrates with Cassandra
InfiniteGraph3.0 , commercialJavaDistributed and cloud-enabled
JanusGraph0.5.2 JavaOpen source, scalable, distributed across a multi-machine cluster graph database under The Linux Foundation; supports various storage backends ; supports global graph data analytics, reporting, and ETL through integration with big data platforms ; supports geo, numeric range, and full-text search via external index storages.
MarkLogic8.0.4 , freeware developer versionJavaMulti-model NoSQL database that stores documents and semantic graph data ; also has a built-in search engine
Microsoft SQL Server 2017RC1SQL/T-SQL, R, PythonOffers graph database abilities to model many-to-many relationships. The graph relationships are integrated into Transact-SQL and use SQL Server as the foundational database management system.
Neo4j4.1.1 Java,.NET, JavaScript, Python, Go,
Ruby, PHP, R, Erlang/Elixir, C/C++, Clojure, Perl, Haskell
Open-source, supports ACID, has high-availability clustering for enterprise deployments, and comes with a web-based administration that includes full transaction support and visual node-link graph explorer; accessible from most programming languages using its built-in REST web API interface, and a proprietary Bolt protocol with official drivers; most popular graph database in use as of 2019
OpenLink Virtuoso8.2 C, C++Multi-model relational database management system that supports both SQL and SPARQL for declarative operations on data modeled as SQL tables and/or RDF Graphs. Also supports indexing of RDF-Turtle, RDF-N-Triples, RDF-XML, JSON-LD, and mapping and generation of relations from numerous document types including CSV, XML, and JSON. May be deployed as a local or embedded instance, a one-instance network server, or a shared-nothing elastic-cluster multiple-instance networked server
Oracle Spatial and Graph; part of Oracle Database12.1.0.2 Java, PL/SQLProperty Graph and RDF Graph capabilities as features in multi-model Oracle Database:
  1. Property Graph - consisting of a set of objects or vertices, and a set of arrows or edges connecting the objects. Vertices and edges can have multiple properties, which are represented as key-value pairs. Includes PGQL, a SQL-like graph query language and an in-memory analytic engine with 50+ prebuilt parallel graph algorithms
  2. RDF Semantic Graph: comprehensive W3C RDF graph management in Oracle Database with native reasoning and triple-level label security.
OrientDB3.0.28 JavaSecond-generation distributed graph database with the flexibility of documents in one product ; licensed under open-source Apache 2 license; and has full ACID support; it has a multi-master replication and sharding; supports schema-less, -full, and -mixed modes; has security profiling based on user and roles; supports a query language similar to SQL. It has HTTP REST and JSON API.
RedisGraph1.2.2 Redis Source Available LicenseCIn-memory, queryable Property Graph database which uses sparse matrices to represent the adjacency matrix in graphs and linear algebra to query the graph.
SAP HANASPS12 Revision 120C, C++, Java, JavaScript & SQL-like languageIn-memory ACID transaction supported property graph
Sparksee5.2.0 , commercial, freeware for evaluation, research, developmentC++High-performance scalable database management system from Sparsity Technologies; main trait is its query performance for retrieving and exploring large networks; has bindings for Java, C++, C#, Python, and Objective-C; version 5 is the first graph mobile database
Sqrrl Enterprise2.0 JavaDistributed, real-time graph database featuring cell-level security and mass-scalability
Teradata Aster7 Java, SQL, Python, C++, RMPP database incorporating patented engines supporting native SQL, MapReduce and graph data storage and manipulation; provides a set of analytic function libraries and data visualization
TerminusDB2.0.5 Prolog, Rust, JSON-LDModel driven graph database designed for knowledge graph representation

Graph query-programming languages

  • AQL : a SQL-like query language used in ArangoDB for both documents and graphs
  • Cypher Query Language : a graph query declarative language for Neo4j that enables ad hoc and programmatic access to the graph.
  • GraphQL: an open-source data query and manipulation language for APIs
  • Gremlin: a graph programming language that is a part of Apache TinkerPop open-source project
  • SPARQL: a query language for RDF databases that can retrieve and manipulate data stored in RDF format