← Back to the journal

DataFocus · Journal

Ontology vs RAG: Numbers Need a Query, Clauses Need Retrieval

Route by the shape of the answer: vector RAG for passages, GraphRAG for corpus-wide themes, an ontology-bound query for any number computed from tables. One worked question, three paths, and a side-by-side table of what each mechanism can vouch for.

Route by the shape of the answer, not by the fashion of the method. When the answer is a passage someone already wrote (a policy clause, a contract term, a support article), vector RAG is the right mechanism: embed, retrieve, quote. When the answer is a number that has to be computed from rows in an ERP, CRM or warehouse, no passage contains it; the model must generate a query, and it will generate the wrong one unless something tells it which records are the same customer, how the tables join and what the metric means. That something is an ontology. GraphRAG belongs to the first family, not the second: it extends retrieval to themes across a whole corpus, and it still cannot total an invoice.

Most enterprise questions want a number and a rule in the same breath. The rest of this post shows what each mechanism actually does, what the published benchmarks say, and how to split one question across them so that every claim in the answer carries its own evidence.

What does vector RAG retrieve, and what can it never retrieve?

The pipeline is short: chunk the documents, embed the chunks, find the k chunks nearest to the embedded question, paste them into the prompt. It works when three conditions hold at once: the answer exists more or less verbatim in some chunk, a handful of chunks is enough, and the question is phrased the way the document is written.

Each condition fails in a predictable place.

  • Global questions. Microsoft Research's 2024 GraphRAG paper (Edge et al., arXiv 2404.16130) states that "RAG fails on global questions directed at an entire text corpus", such as "what are the main themes in these documents". Top-k retrieval sees k chunks and nothing else.
  • Aggregates. "Total approved purchase value by department last quarter" is written in no document. Retrieving rows as text and asking the model to add them is fragile at ten rows and hopeless at ten thousand.
  • Definitions. "How many active customers do we have" depends on what active means and on whether "Customer A" in the CRM and "Customer A" in the ERP are one company. DataFocus's product brief names this gap directly: models in the enterprise lack context such as whether "Customer A" in CRM, ERP and a contract is the same company, what "delivered" means, and which rule version is in force.

A similarity score measures how close the wording is. It does not measure whether the passage is current, whether it is the authoritative version, or whether an auditor would accept it. Those are properties of the source, and the index does not know them.

What does GraphRAG add, and what does it keep?

GraphRAG, from Microsoft Research, has an LLM extract entities and relationships from the documents into a graph, clusters related entities into communities, and pre-summarizes each community. At question time it answers from the summaries rather than from raw chunks. Microsoft's February 2024 research blog describes the method as using "LLM-generated knowledge graphs to provide substantial improvements in question-and-answer performance" on narrative private data; that is the vendor's own description. The paper (2024, revised 2025) reports better comprehensiveness and diversity of answers for global sensemaking questions over datasets in the one-million-token range.

Two properties follow from the design and matter for enterprise data:

  1. The graph is the model's opinion. Entities and relationships are extracted from text. That is useful for discovery, but nobody has approved that "Supplier X" and "X Ltd." were merged correctly, or that a relationship label is right.
  2. It is still a text method. It summarizes what documents say. It does not compute an overdue balance from a ledger, because the ledger was never in the corpus as prose.

GraphRAG is therefore a better fit than vector RAG for "what complaints recur across 20,000 service tickets", and the same poor fit for "what is our overdue receivables balance".

Why not skip retrieval and let the model write SQL?

The obvious alternative for numbers is plain text-to-SQL: show the model the schema, let it write the query. Academic benchmarks suggested this was nearly solved. On Spider 1.0, prompt engineering alone (DAIL-SQL, Gao et al., arXiv 2308.15363, 2023) reached 86.6% execution accuracy.

Enterprise schemas tell a different story. Spider 2.0 (Lei et al., arXiv 2411.07763, November 2024) built 632 real-world workflow problems on BigQuery- and Snowflake-class databases that often contain over 1,000 columns; an o1-preview code-agent framework solved 21.3% of them, against 91.2% on Spider 1.0. The leaderboard has climbed since, so read that as a 2024 snapshot. BEAVER (arXiv 2409.02038, revised May 2026), built from private enterprise warehouses with 812 tables, reports state-of-the-art agentic frameworks with GPT-5.2 at 10.8% accuracy, rising to 30.1% when subtask hints are supplied.

The pattern across these numbers is not a shortage of intelligence. It is a shortage of context: which of the thousand columns, which join path, what "approved" means here. Hints help because hints are context. An ontology is that context made permanent and owned.

What does an ontology layer give the query?

The most direct evidence is the data.world benchmark (Sequeda, Allemang and Jacob, arXiv 2311.07509, November 2023). On an enterprise insurance SQL schema, GPT-4 with zero-shot prompts over the raw database answered 16% of questions correctly; the same questions posed over a knowledge-graph representation built from an ontology plus mappings reached 54%. The limits are plain: one domain, one schema, a 2023 model. It shows a direction, not a number to expect on your data.

What goes into such a layer, using DataFocus OT as one concrete example, following the structure its brief describes:

PartWhat the model gets from it
Objects and relationshipsTables from different systems organized under business objects, with how they relate and what each relationship means, shown in an ontology graph
Rules and knowledgeA document center holding policies, rules and metric definitions, linked to the data they govern
Indicators, actions, permissionsDefined metrics, executions that calculate, check and write back, and who may see and do what

The brief's own definition is worth quoting because it names the parts that retrieval lacks: an ontology is "a model of your business, covering its objects and how they relate, the rules and definitions you work by, the actions that can be taken, and who may see and do what."

Three mechanisms do the work:

  • Bounded generation. The AI follows the objects and relationships defined in the ontology instead of guessing joins from column names. In DataFocus's homepage demo, until a customer-identifier mapping across CRM, ERP and contracts is confirmed, agents do not treat two similar names as one company.
  • Receipts, not recollection. Every query returns the SQL that ran, the tables it used and a data fingerprint. The brief puts it bluntly: answers "come from the SQL that actually ran ... instead of figures estimated by a language model."
  • One definition, every consumer. A business definition is set once and reused by search analysis, dashboards, control panels, the ontology agent and external agents, so they return the same figures. The brief's example, on built-in Chinese sample data, shows a business user in Data Search and Claude Code connected through MCP getting matching totals by requesting department, with the agent's answer citing the SQL and a receipt field evidenceRowsSha256.

That last point is the whole difference in one line. RAG grounds an answer in passages that look relevant. An ontology-bound query grounds it in a query you can rerun, over joins and definitions that a named owner set.

Three mechanisms, side by side

Vector RAGGraphRAGOntology-bound query
Unit of groundingPassages ranked by similarityLLM-built graph and community summariesA query over owner-defined objects, joins and metrics
Who vouched for the structureNobody; the index is automaticThe extracting modelA business owner
Computes an aggregateNoNoYes
Same entity across systemsNot resolvedMerged by extraction, unapprovedExplicit, confirmed mappings
Which rule version appliesWhichever embeds closestSummarized togetherThe rule linked to the object, with the version in force
Evidence returnedCited chunksSummaries plus supporting chunksSQL, tables used, data fingerprint
Cost to startLowestAn LLM indexing pass over the corpusModeling work and owners who maintain it

One question, three paths: a worked example

Consider a hypothetical procurement team asking an agent: "Which purchase requests breached our approval SLA in October, and which rule applies?" The data model is the built-in purchase-approval ontology that DataFocus's brief uses as its example: nine tables covering purchase requests, approval events, process variants, bottlenecks, compliance findings, improvement tasks and audit records, with compliance rules, SLA and bottleneck rules, event-log definitions and the write-back and audit procedure held in the rules-and-knowledge part. The walk-through below is illustrative, not run.

Path A, vector RAG. The index returns the paragraphs of the procurement policy that mention "SLA" and "approval". If the policy was revised, both the old and the new clause come back, because they are worded alike. The list of breaching requests does not come back at all; it was never a paragraph. A model under pressure to answer will produce one anyway.

Path B, GraphRAG. The community summary for "approval process" describes what the documents say about SLAs, escalation and known bottlenecks. A reviewer learning the process would find it useful. The team asked for a list, and a summary is not a list.

Path C, ontology-bound query plus scoped retrieval.

  1. Classify the question: a list from operational tables, plus a rule from documents.
  2. Resolve objects: purchase request and approval event, with the relationship between them already defined; "SLA breach" is a metric defined once in rules and knowledge, not re-derived per question.
  3. Generate and run the query. Return the rows, and keep the SQL, the tables used and the data fingerprint as evidence.
  4. Retrieve the SLA rule from the document center because it is linked to the approval-event object, not because its embedding landed near the question. The link, and the version in force, is what removes the two-clause ambiguity of Path A.
  5. Answer with provenance per claim: the query behind the list, the document reference behind the rule.

Step 4 is the one most teams skip. Unscoped retrieval returns a superseded policy as readily as the current one. DataFocus's homepage demo (simulated data) makes the point concretely: a support policy moves from a 24-hour to a 4-hour response; until the owner approves the change, agents keep answering with the old rule, and after approval the answers given under the old version stay on record, unrewritten. That behavior is only possible when the rule is an object with a version, not a chunk with a score.

Decision rules

The question looks likeUseWhy
"What does our travel policy say about…"Vector RAGThe answer is a passage; similarity finds it
"What themes recur across all incident reports"GraphRAGGlobal question; top-k chunks cannot cover the corpus
"Revenue by region last quarter", "invoices over 90 days overdue"Ontology-bound queryMust be computed; depends on joins and metric definitions
"Which requests breached SLA, and under which rule"Ontology-bound query plus scoped retrievalNumber from tables, rule from the linked document
Small, single-system schema with clear namesPlain text-to-SQLAn ontology is overhead when there is nothing to reconcile

Four checks for your own situation:

  • If two teams would give different answers to the same metric question, you have a definitions problem. More retrieval will not fix it.
  • If the same entity carries different IDs across systems, you need explicit mappings, not embeddings.
  • If an auditor will ask how a number was produced, you need a rerunnable query as evidence, not cited chunks.
  • If your content is mostly unstructured text and nobody needs exact figures, RAG or GraphRAG is the simpler and better fit.

Trade-offs

An ontology costs modeling work: someone defines objects, relationships and metrics, and owners keep them current when the business changes. GraphRAG costs an LLM indexing pass over the whole corpus and yields a graph nobody approved. Vector RAG is the cheapest to start and the hardest to make exact. None of the three replaces the others. The mistake is pointing one mechanism at all three kinds of question and then blaming the model.

Next step

To see how one ontology product links tables, rules and evidence, read DataFocus's OT product brief, which walks through the purchase-approval ontology used above and shows the matching-totals example with its SQL receipt.