Zero Labs
Industry News / AI

Does the Graph Earn Its Cost?

Source · Towards AI By Sonja Bacinski

From the publisher’s feed, collected in the ZeroLabs newsroom.

I stored the same data as documents and as a graph, and asked both the same six questions. The graph didn’t reveal anything new, but it changed where the work happens.Graph databases are often sold with the promise that they’ll reveal connections hidden in your data. I believed that for a while. Then I realised the connections weren’t hidden anywhere. They were already in the data, and the graph just stores them differently.So in my final-year project, I tested what a graph database actually buys you. I built a graph next to an existing document store of real lending data, and asked the same six questions of both.The short version: for questions you already know how to ask, a graph doesn’t reveal anything that wasn’t already in your data. What changes is where the work of connecting records happens. In the document store, every query rebuilds the connections for itself. In the graph, a tested pipeline builds them once, when the data is loaded, and every query reuses them.I think that’s worth paying for when the same connecting logic keeps being rebuilt across reports and tools. It isn’t when a single document already holds the answer.Comparing two data models fairly is harder than it looks, and I was lucky with the setup. I didn’t choose the database: ArangoDB was already there, behind the commercial system my data came from. My part was the graph. I designed the model, built the pipeline that loads it and the checks that verify it, and wrote the queries for both versions. ArangoDB stores documents and graphs side by side and queries both in the same language, AQL, so any difference in the shape of two queries couldn’t come from syntax. I compared that shape, not speed.I built the graph, and I wanted it to win, so I couldn’t just pick the version that looked better to me. Before comparing anything, I set three tests and used them on every pair of queries:Simplicity: how many query blocks, collections and steps it needs.Clarity: can you tell what it’s for just by reading it?Ease of change: if the question changes a little, is the change small, or do you rewrite the whole query?What I found: the work is conservedThe data came from a commercial system, so I can’t show the real details. The example below uses a made-up domain instead, with queries of the same shape as the real ones.A buyer has one purchasing policy for its approved suppliers, with one rule per supplier that sets that supplier’s prices and terms. Every order is placed with one supplier and has to follow that supplier’s rule. Once the order is placed, it’s shipped.In the graph, each of these is a record, and each link between them is stored once, with a name. The policy has rules (POLICY_HAS_RULE), each rule governs the orders placed under it (RULE_GOVERNS_ORDER), and each order is placed with a supplier (ORDER_PLACED_WITH_SUPPLIER) and fulfilled by a shipment (ORDER_FULFILLED_BY_SHIPMENT). The documents don’t store these links, so every query has to rebuild them.Here is one of the path questions: for a given purchasing policy, which fulfilled orders were placed under it, which rule covered each order’s supplier, and which shipment delivered each order?The path of one question. At each link, the graph follows a stored, named link. The documents rebuild it inside the query.The document query answers it with three fragile tricks:A manufactured key. It builds the shipment’s ID by gluing two of the order’s fields together: CONCAT(order.carrier_code, “_”, TO_STRING(order.carrier_consignment_id)). That depends on a naming convention that exists only in people’s heads, and it assumes each order has exactly one shipment.A name match. It matches each order to its rule by comparing supplier names in lowercase, so a trailing space or a renamed company breaks it without any error.A nested-list search. It finds the rule by searching a list stored inside the policy, so it depends on that list keeping the same shape across records from different sources.The graph query has none of these. It starts from the same policy and follows its named links: to the policy’s rules, from each rule to the orders it governs, and from each order to its supplier and its shipment.The work didn’t disappear, though. It ran once, when the data was loaded and the links were built, and every query reuses the result. That’s what I mean by the work being conserved: the same logic still exists, but it runs in one place.Most of it went into one link, RULE_GOVERNS_ORDER. Building it means doing the same supplier-name match the document query does, and deciding, once, what happens when two rules name the same supplier. The document query answers that with FIRST(), which silently takes whichever match comes first, depending on the order the documents happen to be in.The pipeline has to answer it explicitly, write the answer down and test it.Across all six pairs, the pattern held. Manufactured keys, name matches and nested-list searches appeared only on the document side, and five of the six document queries rebuilt an ID by gluing fields together. A document store built for analysis could also store those IDs when the data is loaded, but then it pays the same cost in its own pipeline, which is my point.On step count, the graph actually did worse: in most pairs it took more steps. What differed was the kind of step. Every graph step does the same simple thing, following one named link to the next record, so you can read what a query is for from the link names. The document versions mix lookups, status filters, nested fields, manufactured keys and name matching.Ease of change showed most clearly in a query that broke spending down four ways. Adding a fifth to the graph version would take one more link to follow and one more entry in a list. In the document version, I’d have to find the right field in records from different sources and check they were named the same way.The pair that went against meOne comparison contradicted my thesis, and it’s the one I’d want to see if I were reading this.The question was “give me everything about one shipment”. The shipment document already holds its carrier, origin, destination, customs classification and insurance, with its milestones in a nested list, so the document version is a single fetch. The graph version needs a separate step for every detail that became its own record, plus one for each of three event streams: planned milestones, status changes and tracking scans. For that question, the graph is worse in every way that matters.I think that’s a fact about my modelling choice more than about graphs. I built the schema around a process, how an order moves from policy to rule to supplier to shipment, so questions about the process became short, named paths. A question about one thing’s details isn’t a process question, and the same split that made the process easy to follow scatters one shipment across many steps. The document store made the opposite choice: it kept the shipment together and left the process implicit.So the real boundary, I think, is between a model built around processes and a model built around things, and the question you ask decides which one looks clumsy. That’s uncomfortable, because it means a comparison like mine partly compares two modelling decisions, not only two technologies. The two schemas were built for different jobs. Mine answers questions about how a process connects. The document store takes in records from several platforms that all name things differently, and it does that well.It’s also the most useful thing I learned. The model follows the question, and if you model around one kind of question, expect to pay on another.Why moving the work is worth paying forIf the logic still exists either way, why move it at all? Because logic that gets rebuilt in every query gets rebuilt slightly differently each time.In my six document queries, the same ID-building logic appears five times. My copies match because I wrote them all, so what follows is how drift usually happens, not something I measured. In a typical company, the same logic also ends up in a dashboard, a monthly report, a reconciliation script written in a hurry and an Excel file that was meant to be temporary. Those are four versions, written by different people at different times, and nothing in the system knows they’re supposed to agree. When a source changes a field, or someone handles a missing value differently, they drift apart, and months later two numbers disagree in a meeting.Keeping the logic in one pipeline means you write and test it once. That doesn’t make it right, and a mistake there reaches every report that uses it. But it’s one place to find and fix it, instead of four versions drifting apart. The benefit is control and audit.The pipeline isn’t free. Mine extracts, normalises, links and loads the data. It gives every record a fixed ID, so a rerun updates records instead of duplicating them, and checks after loading confirm that every link points to a record that exists. I think it’s cheaper to pay that cost once, in the pipeline, than again in every query.History matters too, especially in regulated lending, where regulators and auditors often ask what was in force when a decision was made. When each change is stored as its own record, linked to what it changed, that becomes a simple filter rather than something each report rebuilds. Most of that comes from storing changes as records, which a history table can also do. The graph adds a named link from each change to what it changed, which makes these questions easier to ask. That’s a much smaller claim than meeting any regulation, and it’s the only one my evidence supports.A temporal graph goes one step further, because every link carries the time it happened. Once your records are mapped into one, the same graph can be reused in two ways. You can ask for the network as it was on a date, without writing that query each time. Or you can run algorithms that look at the whole network at once, which my six questions didn’t touch. Temporal motifs are one example. They count small patterns of events in a set order within a set time, like money that arrives in an account and leaves again within an hour.Neither of these needs your records to leave the database they live in. For the motif analysis in my thesis, I built the network from the documents with a script and loaded it into Raphtory, a temporal graph library. The catch is that a one-off script brings the glued keys and name matches back, now living in Python. So the question isn’t where the graph lives, but whether mapping the records into it is a lasting, tested piece of work, or something rebuilt for each analysis.Two things this doesn’t show. I didn’t compare speed: my dataset fit entirely in memory, where almost any query is fast, so nothing here says the graph is faster. And I didn’t measure what it costs to keep a graph next to the document store. It has to stay in step with its source, and one rebuilt nightly from data that changes hourly is wrong in a different way.So I wouldn’t migrate by default. I’d build a separate analytical layer next to the document system of record, fed by a pipeline, and let the document store keep doing what it’s good at. I’d reach for a graph in two situations. One is when the same connecting logic keeps being rebuilt across many reports and tools. The other is when “what was true on this date?” is a regular requirement rather than an occasional favour. Either way, model it around the questions you actually intend to ask, because the modelling decision does more work than the technology choice.Named links and AI toolsCompany data is increasingly queried by AI tools, not only by people, and stored, named links could matter for them too.Look again at the name match. Nothing in the documents says that the supplier name inside a rule is supposed to match the supplier name on an order. That knowledge lives in the head of the analyst who wrote the query, and it leaves with them. Conventions like that, and the glued key standing in for a join, have to be rediscovered by every analyst who touches the data. More and more, they also have to be rediscovered by every AI tool asked to query it.An AI tool can infer those conventions by spotting patterns, and it often will, confidently. But it can’t reliably tell you which parts of its answer were inferred. A graph query can only follow connections that were built and checked when the data was loaded. That’s a narrower ability, and an easier one to audit. Named links are documentation a program can read.This is strongest against a document store where connections are conventions. It’s much weaker against a relational database with declared foreign keys, or a semantic layer that defines business terms for machines, because both can state the same structural facts without a graph.There’s a difference in level, though. A semantic layer usually describes the schema: which tables join, and what each metric means. That tells an AI tool how to write a query. My graph went a level lower and stored the links between the records themselves: in the example, which rule governed a given order, and which shipment delivered it. It also captured when each change happened, and the facts the pipeline derived using rules. A relational database can store all of that too. What the graph adds is that those facts are connected to the records they describe by named links, so you can trace which rule applied, and when.Most companies won’t move their whole database into a graph just so AI tools can read it more easily, and I wouldn’t recommend it. But the separate layer I’d recommend anyway, fed by a pipeline and kept next to the system of record, might be enough. AI tools could read its named, checked links instead of guessing from the raw documents. That only works if the layer itself can be trusted. It has to record what happened and when, record how each fact was derived, and keep checking itself against the source. Then any answer can be verified rather than just believed. I haven’t tested whether that actually makes AI answers more reliable.The conclusion I can actually defendI started this project wanting to show that the graph was better. What I can actually defend is a smaller claim: the graph moved the work of connecting records into one tested pipeline, without adding any information that wasn’t already there. A graph isn’t the only way to do that: a relational database with declared foreign keys gets much of the same benefit. Whether moving the work pays off depends on how often a business rebuilds that logic, and how often it needs to ask what was true on a past date.I hold that at three levels of confidence. The design works for the questions I tested, on a narrow slice of one portfolio. Those questions all had a fixed number of steps, on data that fit in memory. So my result doesn’t cover questions that follow links many steps deep, like shortest paths, or how traversal holds up on a large production system. I believe that’s where a graph database earns more of its cost, when the question really has that shape, and it’s what I’d most like to test if I get the chance. The business case looks promising but is untested. And I know what data would settle it: many investors and loan originators, not one. A lot of technical writing quietly treats the first as if it proved the second.If there’s one thing I’d want a reader to take away, it’s that the question comes first. It decided what my model had to do well, and a comparison like mine is only as fair as the questions behind it.So I finished with a better question than “should I use a graph?”. Once connections are explicit, checked and readable by machines, can an AI system use them more reliably than it can rebuild them for itself? And can a graph layer next to the existing database give it that, without moving everything?That’s what I’m building next. Liquet is built in public, with synthetic data for a made-up wealth manager: its own cash records and its custodian’s monthly statement. It asks the question every finance team answers at month-end: does our cash book agree with the bank, and if not, why? That’s a question about records, not schemas: which statement line matched which cash entry, under which rule, and on which day.The records stay in a document database, and a graph layer gives each connection a clear name and meaning. I’m building that layer in Raphtory and saving the graph after every run, so you can go back to any month and see what was matched, what wasn’t, and what was known at the time. Rules do the matching, an AI agent investigates what’s left and explains each difference with evidence, and a person approves it. The principle is simple: rules for what you can state, an agent for what you can’t, and a graph as the shared, checkable context for both. Then I’ll test whether the agent is more reliable and more traceable working through the graph layer than from plain tables. Time is part of it from the start, because every reconciliation is about what was true, and what was known, on a given day.If your team rebuilds the same joining logic across reports, I’d like to hear how you keep the copies in step.This is a shorter version of Does the Graph Earn Its Cost? on my site, which has the full queries, the method, a section on temporal motifs and the references. The research, the graph model, the pipeline, the queries and the analysis are my own work from my final-year project. I used AI tools (Claude) to help me edit it.Does the Graph Earn Its Cost? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.