Accent colour
 
Shortcuts: press ?
 

Graph Databases: A Practical Guide to Connected Data at Scale

Muhammad Tahir December 05, 2026

The Panama Papers problem

In April 2016, journalists around the world started publishing stories from a leak of 11.5 million documents — emails, contracts, bank records — describing how wealthy people and companies used offshore firms. The leak, known as the Panama Papers, was far too big for any one newsroom. More than 370 journalists in about 80 countries worked on it for a year, coordinated by the International Consortium of Investigative Journalists.

The technical problem was not storage. Any ordinary database could hold 11.5 million records. The problem was the connections. A name in one document was a director in another, a shareholder in a third, and the owner of a company registered at an address shared by four hundred other companies. The story lived in the links between records, not in the records themselves. The ICIJ's team reached for a graph database — Neo4j — because that was the tool built for exactly this shape of problem. Reporters could ask questions like "show me everyone connected to this address through two or fewer hops" and get an answer in seconds, a question that would have taken a relational database hours of expensive joins.

That is the core idea of this article. Most databases store things. Graph databases store things and the relationships between them, and they treat the relationships as first-class citizens rather than as an afterthought you reconstruct with joins. For a large class of problems — fraud, recommendations, knowledge graphs, network maps — that difference changes what is practical.

What makes a database a graph database

A graph database stores data as nodes and edges. A node is a thing: a person, a product, an account, a web page. An edge is a relationship between two nodes: this person owns this company, this account sent money to that account, this user bought this product. Both nodes and edges can carry properties — a person has a name and a birth date, an ownership edge has a percentage and a date.

The idea comes from graph theory, a branch of mathematics that is nearly three hundred years old, but the practical breakthrough is about how the database stores the edges. In a relational database, a relationship is implied: a foreign key in one table points at a row in another, and the database finds the connection at query time by matching values. In a graph database, the edge is stored as a direct pointer from one node to the next. The database does not have to search for the connection; it follows it. This is sometimes called index-free adjacency, and it is the reason graph queries stay fast as the data grows.

To see why that matters, imagine a fraud investigator asking for everyone within three steps of a suspicious account. In a relational database, each step means joining a table of millions of rows against another table of millions of rows, and the cost multiplies with every step. Three steps in, the query can take minutes or hours. In a graph database, the same question is a walk: start at the account, follow its edges, follow the next set of edges, and stop. The work depends on how many connections the starting account actually has, not on how big the whole database is. On a network where each account has a handful of connections, the answer comes back before you have finished reading the question.

The first commercial native graph database, Neo4j, was founded in 2007 and released its first version in 2010. Since then the field has filled out: Amazon launched its managed graph database Neptune in November 2017, Microsoft added graph support to Cosmos DB the same year, and open-source options like ArangoDB and JanusGraph cover teams that want to run their own. The market is still small next to relational databases, and that is fine. Graph databases are not trying to replace the relational database. They are trying to do the jobs the relational database does badly.

Property graphs and triples: two ways to draw the map

There are two main flavours, and the difference trips up a lot of first-time users. The property graph model — used by Neo4j, Neptune, and most of the popular systems — stores nodes and edges with labels and properties, as described above. A person node might carry the label Person and the properties name and born. An edge might carry the label OWNS and a since property. It is flexible, easy to read, and close to how people draw diagrams on a whiteboard.

The other flavour is the RDF triple store, built on a W3C standard. Data is stored as triples: subject, predicate, object. "Alice — owns — Company X" is a triple. "Company X — registered at — Address Y" is another. RDF is older, more formal, and stronger where strict standards matter: linked open data, government datasets, and academic knowledge bases. It comes with its own query language, SPARQL, which became a W3C recommendation in 2008.

For most application teams, the property graph is the easier starting point. Its query languages read more like the code you already write, and its tooling is built for developers rather than for standards committees. RDF earns its place when you need to merge datasets from different organisations, or when your data has to be understood by machines you do not control. Neither is wrong. They answer different questions, and some systems now support both.

Where graphs beat tables

The honest test of any database is not how elegant its model is, but which questions it answers cheaply. Graph databases earn their keep in a few clear places.

Fraud detection is the classic one. A stolen credit card used once looks normal. The same card used by five accounts that share a phone number, a device, and an address looks like a fraud ring, and the pattern only becomes visible when you look at the connections. Banks and payment companies run graph queries over transaction networks precisely because a ring is a shape, not a row. A single transaction can be legitimate; a shape made of twenty transactions is a story. That is why the Panama Papers team and fraud teams reach for the same tool: both are hunting for shapes.

Recommendation engines are a second home. "People who bought this also bought that" is a graph question: start at a product, follow the edges to the people who bought it, then follow their edges to the other products they bought. A streaming service can do the same with viewing history, and a social network can suggest friends of friends. The relational version of this query is a pile of self-joins that gets slower with every step. The graph version is a short walk.

Knowledge graphs are a third. Google launched its Knowledge Graph in May 2012, and the idea has spread far beyond search: companies now build internal knowledge graphs of their products, customers, documents and experts, so a support agent can ask "which customers use this feature, and who in our company knows it best?" and get an answer drawn from several systems at once. A knowledge graph is a way of joining data that was never designed to be joined, and the graph model is forgiving about messy, half-structured information in a way tables are not.

Network and IT topology is a fourth, quieter one. A data centre is a graph: servers connected to switches connected to racks connected to power feeds. When a switch fails, the interesting question is "what depends on this, directly or indirectly?" That is a graph traversal, and teams that run it as one can find the blast radius of an outage in seconds instead of tracing cables on a whiteboard.

Where a graph is the wrong tool

None of that means you should put everything in a graph. A graph database is a poor choice for a surprising number of ordinary jobs, and knowing where to stop is part of using one well.

Simple, well-structured data belongs in a relational database. An invoicing system, a payroll table, a list of users with addresses — these are tables, and tables handle them with less fuss, better tooling, and decades of operational knowledge. SQL vs NoSQL is a genuine trade-off, and for tabular data with stable relationships the relational answer usually wins.

Heavy aggregation is also a weak spot. A graph database is built to walk connections, not to sum a billion rows. A monthly sales report, a count of events by region, a roll-up of revenue by product line — these are jobs for a relational database or a warehouse, and a graph database will do them slowly and awkwardly. That is why teams that use graphs usually keep their warehouse alongside them: the graph answers connection questions, and the warehouse answers counting questions. The two tools are complementary, and data lakes and warehouses still have their place.

Bulk writes can be another problem. Loading millions of edges into a graph is slower than bulk-loading rows into a table, because each edge has to be attached to its nodes. And the operational ecosystem is thinner: fewer hosted options, fewer DBAs who know the system, fewer Stack Overflow answers at 2 a.m. These are not reasons to avoid graphs. They are reasons to use them where the payoff is clear and to leave the rest where it is.

Choosing and starting with a graph database

If you have a problem shaped like a network, the practical question is which system to pick and how to start without betting the company on it.

Neo4j is the default choice for most teams. It has the largest community, the most learning material, and a query language, Cypher, that reads almost like English: MATCH (p:Person)-[:OWNS]->(c:Company) RETURN p, c. It runs as a managed cloud service (Aura) or self-hosted, and its free tier is generous enough for a serious prototype. Amazon Neptune is the pick if you are already deep in AWS and want a managed service that speaks both property-graph and RDF languages. ArangoDB is worth a look if you want one database that does graphs, documents and key-value together. TigerGraph aims at the high end: very large graphs and heavy analytics.

The query language matters more than the brand. Cypher is the most widely taught and the easiest to learn. Gremlin, from the Apache TinkerPop project, is more powerful for complex traversals but harder to read. SPARQL belongs to the RDF world. If your team has to learn one, pick the one with the best tutorials and the biggest community for your use case, because the language is where your team will spend its time.

A sensible first project follows a pattern that has worked for many teams. Pick a question your current database answers badly — "find the accounts connected to this fraud case", "recommend products from purchase history", "show me everything connected to this customer" — and build a small graph from a copy of the data, not from the live system. Model only the entities and relationships the question needs. Load a few thousand records, write the query, and compare the result and the speed against the relational version. If the graph is not clearly better, stop. You have learned something cheaply. If it is, you have a prototype and a number to show your team.

A few modelling habits will save you pain later. Keep node labels broad and edge labels specific: Person and Company as nodes, OWNS, WORKS_FOR, TRANSFERRED_TO as edges. Put data that changes often on the edge, not the node. Resist the urge to model everything; a graph that tries to hold your whole company becomes a swamp, not a map. And think about direction: an edge from A to B is not the same as an edge from B to A, and getting the direction wrong will quietly return wrong answers.

A worked example: one question, step by step

It helps to see a graph query as a story rather than as code. Suppose a payment company notices a chargeback on an account called A. One chargeback is not a fraud ring; it is a Tuesday. The analyst wants to know whether account A is connected to other accounts that have also charged back, and how.

In a graph, the analyst starts at A and asks for the accounts that share a device with it. That is one hop. Suppose three accounts share the device. Next, the analyst asks for the accounts that share a phone number with any of those three. That is a second hop, and it brings in four more accounts. Then the analyst asks for the accounts that sent money to any account found so far. That is a third hop, and it brings in six more.

The result is a small network of fourteen accounts, and the analyst can now look at the shape. Do they all share the same two devices? Did they all open within the same week? Have five of them already charged back? If the answers line up, the analyst has found a ring, and the company can close all fourteen accounts at once instead of waiting for each one to charge back in turn.

In Cypher, the query for the first two hops looks like this: MATCH (a:Account {id: "A"})-[:USED_DEVICE|SHARED_PHONE1..2]-(b:Account) RETURN b. The 1..2 means one or two hops. The database follows the pointers and returns the accounts it reaches. In a relational database, the same question is a chain of self-joins across a transactions table with millions of rows, and the analyst would probably give up after the first hop and work from a spreadsheet instead.

The same pattern shows up outside fraud. A support team can start at a customer and walk to every ticket, product, and engineer connected to them. A security team can start at a compromised laptop and walk to every system it touched. A product team can start at a feature and walk to the customers who use it and the revenue attached to them. The shape of the question is always the same: start somewhere, follow the edges, and see what the neighbourhood looks like. Once a team gets used to asking questions that way, it starts seeing graph-shaped problems everywhere, including a few that are better left in a table.

Frequently asked questions

Do I have to move all my data into a graph database?

No, and you usually should not. The common pattern is to keep your system of record — the relational database or the warehouse — where it is, and copy the connected part of the data into a graph for the questions that need it. Many teams run a nightly sync. The graph is a specialist tool sitting next to the general-purpose one, not a replacement for it.

How is a graph database different from a relational database with joins?

Both can answer connection questions, but the cost grows differently. In a relational database, each step outward means joining large tables, so a three-step question can be very expensive. In a graph database, each step means following stored pointers from the nodes you have already reached, so the cost depends on the connections around your starting point, not on the size of the whole database. For one or two steps, the difference is small. For three or more, it is large.

What is Cypher, and do I need to learn it?

Cypher is the query language for Neo4j and several other graph databases. It describes patterns: nodes in parentheses, relationships as arrows, like (a:Person)-[:KNOWS]->(b:Person). It is one of the easier database languages to learn, and the openCypher project published it as an open specification in 2015. If you pick a different system, you will learn its language instead — Gremlin for TinkerPop systems, SPARQL for RDF stores — but the ideas are the same.

Can a graph database handle a billion nodes?

Some can, with the right hardware and design. TigerGraph and Neptune are built for very large graphs, and Neo4j has run production graphs with billions of relationships. But most teams never get near that scale. A graph with a few million nodes is already a large one for most companies, and a modest server handles it comfortably. Scale the design to your actual data, not to a number in a marketing slide.

Is a graph database the same thing as a knowledge graph?

No. A knowledge graph is a thing you build — a connected model of what your organisation knows. A graph database is a tool you can build it in. You can also build a knowledge graph in a relational database, a document store, or a set of files, though it is usually harder. The confusion comes from the shared word "graph". Think of it this way: the knowledge graph is the map, and the graph database is one kind of paper it can be drawn on.

The short version

A graph database is the right tool when the question is about connections: who is linked to whom, how far does the influence reach, what shape does this network make? It is the wrong tool when the question is about counting, summing, or storing neat rows. Most teams that adopt one keep their relational database and add a graph beside it, for the questions the relational database answers slowly or not at all.

The best way to find out if you need one is to try. Take a question your current system struggles with, model it as nodes and edges, and run it. If the answer comes back in a second instead of an hour, you have your answer — and a graph-shaped problem worth keeping.

Was this article helpful?

Muhammad Tahir

Author

 

Get new articles by email

 

Comments