Chapter 1 · Learn

What even is a graph database?

Dots, strings, and why connections beat rows.

← Back to the Learn hub

KNOWS KNOWS LIKES Ana Ben Cleo Jazz Hiking Coffee
The whiteboard picture

It's a whiteboard of dots and strings

Picture a giant whiteboard covered in dots — one for each thing you care about (a person, a product, an account) — with labeled strings tied between them showing how they're related. That's a graph. A graph database is simply a place to store that whiteboard and ask questions about it.

You already think this way. When you sketch your family on a napkin, you draw a circle for each person and a line for each relationship — "parent of," "married to," "sibling of." A graph database keeps that exact mental model and lets you store millions of those circles and lines, then ask questions like "who's connected to whom, and how?"

  • The dots are called nodes — the things.
  • The strings are called relationships or edges — how things connect.
  • Both dots and strings can carry properties — a name, a date, an amount.

The reason this matters is subtle but huge: in a graph, the connections are real, stored things — first-class citizens, just like the dots. You don't have to recompute "who knows whom" every time you ask; the strings are already tied. That single design choice is what makes a graph database feel less like a filing cabinet and more like a map you can walk.

Go deeper: why "the connections are stored" is the whole trick

Think of two ways to keep track of a city's roads. Option one: keep a long list of every intersection, and a separate list of pairs that says "intersection 14 connects to intersection 88." Every time you want to drive somewhere, you must cross-reference those two lists over and over. Option two: draw an actual map, where each intersection already has lines leaving it toward its neighbors. To find a route you just trace the lines.

A spreadsheet is option one. A graph database is option two. Same facts — but in a graph the "lines leaving each dot" are physically there, so following them is the easy, natural motion instead of a chore you redo on every question.

The three building blocks

Nodes, edges, and properties — in depth

A node is a noun. It's a single thing: one person, one bank account, one movie, one device. Nodes usually carry a label that says what kind of thing they are — Person, Account, Movie — so you can ask for "all the people" or "all the accounts" at once.

An edge is a verb that joins two nodes. It has a direction and a type: Ana KNOWS Ben, this account SENT_MONEY_TO that account, this user WATCHED that movie. The direction matters — "Ana follows Ben" is not the same as "Ben follows Ana."

A property is a detail stuck onto a node or an edge. A Person node might carry { name: "Ana", age: 31 }. A SENT_MONEY_TO edge might carry { amount: 250, on: "2026-06-01" }. Properties are where the actual data lives; nodes and edges are the skeleton that holds it together.

Here's the part people miss the first time: edges carry properties too. In a spreadsheet, a relationship is usually just a bare reference — "row 7 points at row 42" — with nowhere to record how they're related. In a graph the string itself can hold a date, a weight, a price, a confidence score. "Ana KNOWS Ben since 2019." "This account SENT $250 on June 1st." "This page LINKS_TO that page with strength 0.8." The relationship becomes a place to store meaning, not just a pointer.

One more building block worth naming: the label. A label is a sticker on a node that says what kind of thing it is. Every customer node wears the Person sticker; every product wears Product. Labels let you ask "give me all the people" or "all the products under $20" without hunting — the database can jump straight to the right group. A single node can even wear more than one sticker (Person and Employee), which is handy when one thing plays several roles.

Ana Ben :Person :Person SENT_MONEY_TO amount: 250 · on: 2026-06-01
One fact, fully labeled: two nodes (each with a :Person label), one directed edge (SENT_MONEY_TO), and properties riding on the edge.
Go deeper: a tiny worked example

Suppose we know three facts: Ana KNOWS Ben, Ben KNOWS Cleo, and Ana LIKES Jazz. In a graph that's three nodes for the people, one node for the genre "Jazz," and three edges. To answer "who does Ana know, two hops out?" you start at Ana's dot and walk the strings: Ana → Ben → Cleo. The answer is Cleo — found by literally following the connections, with no table-joining gymnastics.

Add a property — say each KNOWS edge carries { since: 2019 } — and you can refine the same walk to "friends Ana has known since before 2021." The structure didn't change; you just read a detail off the strings as you walked them.

Graph vs. the spreadsheet

Why a spreadsheet (or SQL table) struggles

A spreadsheet or a relational (SQL) table is fantastic at lists: "here are all the customers, one per row." Where it strains is the moment you ask a connection question — friends of friends, the path money took between two accounts, which products are bought together.

In the table world, "who is connected to whom" is answered by joining tables: line up the customers table against the friendships table against the customers table again, and so on. Each "hop" out from a starting point is another join. Three or four hops — "friends of friends of friends" — and the query becomes slow and hard to read, because the table model was never built to walk connections; it was built to store rows.

The spreadsheet / table way

"Friends of friends" means joining the people table to the friendships table to the people table to the friendships table — one join per hop. The deeper the question, the more joins, and the slower and more fragile it gets.

The graph way

"Friends of friends" means: stand on a dot and follow the strings out two steps. The work matches the question. Going three or four hops deep is just a couple more steps along the strings — not a pile of new joins.

That's the whole difference in one sentence: a table stores rows and makes you reconstruct the connections every time; a graph stores the connections directly, so walking them is the cheap, natural thing to do.

Go deeper: the same question, in a table vs. in a graph

Say you want movie recommendations: "films liked by people who like the films I like." In the spreadsheet world you keep a people sheet, a films sheet, and a likes sheet pairing them up. Answering the question means: find my likes → jump to the films → jump to everyone else who liked those films → jump to their other likes → tally up. Each arrow there is a separate cross-reference across separate sheets, and you have to keep the half-finished answer in your head the whole way through.

In a graph it's one motion: stand on your dot, walk out along LIKES to films, hop to other people who LIKES those same films, then follow their LIKES strings to the films you haven't seen. You never "join" anything — you just keep following strings, and the films that show up most often float to the top. The shape of the walk is the answer.

The plain-English takeaway: spreadsheets and SQL tables are brilliant when the answer is a list you filter ("all orders over $100 last week"). Graphs shine when the answer is a chain you follow ("how is this thing connected to that thing, and through whom?"). Most real systems need both — which is exactly why so many teams end up running a graph alongside their other databases. (More on that in the next chapter.)

More everyday pictures

Three graphs you already understand

You don't need a computer-science degree to read a graph — you read them every day without noticing. Three familiar ones:

  • Your group chat. Each person is a dot; each "is in a chat with" is a string. "Who do my friends and I all have in common?" is a graph question, and your phone answers it by walking those strings.
  • A subway map. Stations are dots, track segments are strings, and the properties on each string are things like travel time. "Fastest route from here to there with one transfer" is a shortest-path walk through that graph.
  • A family tree. People are dots; "parent of," "married to," "sibling of" are labeled strings. "Who's my second cousin?" is just counting hops along the right kind of string.

In every case the interesting questions are about how the dots connect — and in every case a graph answers them by literally tracing the lines, the same way your finger would on a paper map.

When graphs win

When a graph is the right tool

You don't need a graph for everything — a simple list of orders is happy in a plain table. Graphs earn their keep when the relationships are the point. The classic wins:

  • Social networks & org charts — "who's connected to whom," "who reports to whom," "which people sit between these two teams." The connections are the product.
  • Recommendations — "people who bought this also bought that," "movies liked by people similar to you." Recommendations are just well-chosen walks through a graph of who-likes-what.
  • Fraud detection — rings of accounts that quietly route money in a circle are an obvious shape in a graph and nearly invisible in a table. Spotting the shape is the detection.
  • Supply chains — parts, suppliers, factories, and shipments form a web. "If this one supplier fails, which finished products are at risk?" is a walk backward through that web — a graph answers it instantly, a pile of spreadsheets does not.
  • Knowledge graphs & AI — tying together facts, documents, and entities so an AI assistant can retrieve exactly the connected context it needs instead of a flat pile of loosely-related text. This is one of the fastest-growing reasons teams adopt graphs today.
  • Networks & infrastructure — computers, routers, cables, dependencies between services. "If this server goes down, what else breaks?" is, once again, a walk along the strings.
  • Paths & routing — the shortest route between two points, how a signal (or a rumor, or a package) travels through a network. Maps are graphs.

The common thread: the value lives in how things connect, not just in the things themselves. That's precisely what a graph database is built to store and answer — directly.

Go deeper: the fraud-ring shape

Imagine four accounts that each send money to the next, and the last sends it back to the first — a closed loop designed to launder funds. In a table of transactions that loop is buried across thousands of rows. In a graph it's a visible circle: four dots, four arrows, closing back on themselves. Asking "find me any cycle of money movement among accounts" is a natural graph question and an awkward one for tables. That shape-finding ability is why banks reach for graphs.

Honest limits

When a graph is not the right tool

A good tool is honest about what it's bad at. A graph database is not a cure-all, and reaching for one where it doesn't fit just adds complexity.

Skip the graph (or keep it as a sidekick rather than the star) when:

  • Your data is a simple list. A log of orders, a table of sensor readings, a catalog of products with no meaningful links — that's a list, and a plain table or spreadsheet handles it beautifully. If you're never asking "how is this connected to that," a graph buys you nothing.
  • You mostly do big arithmetic over columns. "Sum every sale by region by month" is a number-crunching job. Tools built for crunching huge columns of numbers will beat a graph at that, because that work isn't about connections at all.
  • It's a money ledger or system of record. The database that tracks account balances and processes payments has special rules and decades of purpose-built tooling. A graph isn't trying to replace that core — a point we make explicitly in Chapter 3.

The rule of thumb: if the relationships are the interesting part, use a graph; if they're an afterthought, you probably don't need one. The skill is matching the question to the tool — not forcing every problem to look like a graph.

Quick answers

Mini-FAQ

Is a graph database the same thing as a chart or a bar graph?

No — and it's a common mix-up. The "graph" here is the math/network meaning: dots connected by lines, like a subway map or a family tree. It has nothing to do with bar charts or line graphs you'd make in a spreadsheet. Think "web of connections," not "picture of numbers."

Do I have to throw away my spreadsheets and SQL database to use one?

Not at all. Most teams keep their existing tables for the list-and-ledger work and add a graph for the connected-data questions those tables struggle with. A graph is an addition to your toolbox, not a demolition of it.

How big can a graph get?

Very. Real-world graphs routinely hold millions or billions of dots and strings — think every person in a social network, every transaction in a bank, every page on the web. The whole reason graph databases exist is to store webs far too big to fit on a whiteboard and still answer connection questions quickly.

How do you actually ask a graph a question?

With a query language built for connections. The most common one reads almost like a little drawing of the pattern you're hunting for — you sketch "a person who KNOWS a person who LIKES a thing," and the database goes and finds every match. You describe the shape; it walks the strings. Later chapters show what that looks like in plain English.