Blog
Saved0

Vector database vs application database: what AI agents need from each

The agent said Acme had seven open orders worth $412,000. It had four, worth $268,000. Why similarity search finds candidates but can't answer for current state, and what agents need beside it.

LinkedIn
On this page
  1. The agent counted seven orders. There were four.
  2. What is the difference between a vector database and an application database?
  3. Five things similarity search can't give you
  4. Why do AI agents get totals and counts wrong?
  5. Authorization belongs inside retrieval, not after it
  6. Agents need both, used for different questions
  7. Make operational queries typed, scoped and recorded
  8. Keep the index honest about what it is
  9. Common anti-patterns
  10. Seven rules for vector and application data
  11. The result: candidates and truth, each in its place
  12. Frequently asked questions
  13. How Frozion gives agents both kinds of data access
  14. Sources
The short answer

A vector database finds content that resembles a question. It doesn't hold current state, enforce transactions, authorize by record or compute exact totals, counts and status. AI agents need both: permission-aware similarity search for documents and evidence, and typed, scoped queries over the application database for anything that must be true right now.

The agent counted seven orders. There were four.

An account manager asks a sales agent a simple question before a renewal call: "How many open orders does Acme have, and what's outstanding?" The agent searches its vector index for Acme orders, gets the eight most similar chunks back, and answers with confidence: seven open orders, $412,000 outstanding.

The real answer was four orders and $268,000. Two of the seven had been cancelled last week, but the index still held the confirmation emails that created them. One was a duplicate: the same order appeared in a PDF and in a CRM note, embedded twice. And one belonged to Acme's European entity, which the account manager isn't allowed to see. A fifth open order, created that morning, hadn't been indexed yet, so it wasn't counted at all.

Nothing malfunctioned. The vector database did its job well: it found text that resembled the question. The design failed because it asked a similarity index to act as a system of record.

What is the difference between a vector database and an application database?

A vector database ranks stored content by how similar it is to a query. An application database stores the current, authoritative state of business records and answers exact questions about them under transactions. One finds candidates. The other holds the truth.

Vector search turns text into embeddings and returns the nearest neighbours. That's powerful for meaning: it finds the clause that matches a question even when the words differ. But "nearest" is a ranking, not an answer. It returns the top k results, it has no notion of whether a document is still current, and two near-identical chunks look like two pieces of evidence.

An application database (usually relational, sometimes document or key-value) is built for the opposite job. It knows that order 4471 exists once, that its status is cancelled, that it belongs to a specific legal entity, and that the change committed at 09:42. Ask it for a count or a total and you get one exact number.

QuestionVector databaseApplication database
What is it for?Finding relevant content by meaningRecording and querying business state
What does a result mean?"These are the most similar items""These are all the records that match"
Current stateWhatever was indexed last, possibly staleThe committed state, now
TransactionsNot part of the modelAtomic, consistent writes
Exact totals, counts, statusNot possible from a ranked sampleNative, exact
Authorization by recordOften by index or metadata filterCan be enforced per record and field
DuplicatesNear-copies look like extra evidenceOne record, one identity

Five things similarity search can't give you

A vector index isn't a weak database. It's a different tool, and five properties of a system of record are simply outside its job.

  1. Transactions. An agent that approves a refund and updates a balance needs both changes to happen together or not at all. Retrieval indexes are written in batches and read by ranking; they don't coordinate writes.
  2. Current state. Embeddings are a copy, taken at indexing time. When a case closes or an order is cancelled, the old text stays in the index until someone re-embeds or deletes it.
  3. Authorization by record. Permission is a property of each record (this customer, this entity, this region) and it changes. Chunks often inherit coarse metadata, or none.
  4. Exact answers. Totals, counts, averages and "is anything still open?" need every matching record, not the eight most similar.
  5. Identity. A record has one key. Its text may appear in an email, a PDF, a ticket and a note, and each copy becomes its own vector.

Why do AI agents get totals and counts wrong?

Because the agent is summing a ranked sample, not querying a set. Top-k retrieval returns the most similar chunks, so anything not retrieved is missing and anything retrieved twice is counted twice.

The model is good at producing a fluent total from whatever it's given. It has no way to know that the ninth matching order fell just outside the cut-off, or that two chunks describe the same invoice. Raising k doesn't fix it. A bigger sample is still a sample, and stale or duplicate chunks get more chances to appear.

The same applies to status. "Is the claim approved?" is a lookup against one field on one record. Answered from retrieval, it becomes a guess from documents that mention approval: the draft that said "pending approval", the email that said "approved subject to conditions", the note that said "approval withdrawn". The model picks the most plausible reading. The database would simply have returned the value.

Authorization belongs inside retrieval, not after it

The European order in the opening scenario is the dangerous failure. A wrong count is embarrassing; a leaked record is a breach. OWASP's 2025 list for LLM applications names vector and embedding weaknesses, including weak access control and leakage across contexts, as a top risk.

Two patterns fail here. The first puts everything in one index and asks the model to "only use what the user may see". The model has already read the restricted content, and an instruction isn't a control. The second filters the answer afterwards, which is too late for the same reason.

Doing this well needs permission data that's as current as the records themselves. That's another argument for keeping operational questions in the application database, where authorization can be checked against live attributes, as attribute-based access control describes. See permission-aware retrieval for how to carry those checks into the index side too.

Agents need both, used for different questions

The fix isn't to drop vector search. It's to route each question to the store built for it.

The agent needs to…UseWhy
Find the clause in a contract that covers late deliveryPermission-aware similarity searchMeaning matters more than exact words
Know whether order 4471 is openTyped query on the application databaseOne authoritative field, current now
Total what Acme owes across open ordersTyped query with an aggregateNeeds every matching record, exactly once
Summarize the last three support conversationsSimilarity search plus record lookupText for content, the record for identity and date
Decide whether a refund is within limitsTyped query plus historyExact amounts and counts, not similar cases
Explain why a policy appliesRetrieval of policy textEvidence for the explanation, not for the decision

A useful test: if two people asking the same question at the same moment should always get the same answer, it's a query. If they might reasonably get different supporting passages, it's retrieval.

Diagram showing an agent's questions split into two paths: similarity search over documents and typed queries over the application database, both filtered by the requester's authority
Route by question type: retrieval finds evidence, typed queries return current state, and both run under the requester's authority.

Make operational queries typed, scoped and recorded

Sending the agent to the database raises its own risk: an agent writing free-form SQL against production tables. The safer pattern is a set of typed queries the agent can call, each one authored and reviewed in advance.

  • Typed collections. Expose business entities (orders, customers, cases) with declared fields and types, not raw tables.
  • Join and result contracts. Declare how entities relate and what shape and grain the result has, so a total can't silently double-count.
  • Scope on every call. Apply the requester's tenant, entity and record permissions inside the query, not in the prompt.
  • A receipt for every answer. Record which query ran, with which parameters, under whose authority, against which data version, and what it returned.

That receipt is what lets you defend a decision later. "The agent said four orders" becomes "query open_orders_by_account returned four rows at 10:14 under the account manager's authority." For more on why free-form text-to-SQL isn't enough, see governed queries for AI agents.

Keep the index honest about what it is

Retrieval still needs discipline, because its outputs end up in front of the model next to exact data.

  • Link chunks to records. Store the source record's key and version with each chunk, so retrieved text can be checked against current state.
  • Prefer the record when they disagree. If a chunk says "approved" and the record says "withdrawn", the record wins, and the conflict is worth logging.
  • Expire and re-index on change. When a record changes status or permission, update or remove the chunks derived from it.
  • Collapse duplicates. Group chunks by source record before they reach the model, so one invoice can't look like three.
  • Label it as evidence. Retrieved text informs the answer. It never instructs the agent and never overrides a field in the system of record.
Side-by-side comparison of the agent's answer from retrieval, seven orders and $412,000, against the database answer, four orders and $268,000, with each discrepancy labelled
The same question answered two ways: retrieval counted stale, duplicate, restricted and missing records differently from the system of record.

Common anti-patterns

Anti-patternWhy it failsWhat to do instead
Answer totals and counts from retrieved chunksTop-k is a sample; misses and duplicates distort the numberRun a typed aggregate query on the system of record
Embed operational records and treat the index as currentEmbeddings are a snapshot; status changes don't propagateQuery current state; link chunks to record versions
One shared index with a "respect permissions" promptThe model has already read restricted contentFilter by tenant, scope and record before retrieval returns
Filter the answer after generationToo late; the leak happened at retrievalApply authority inside every retrieval call and query
Let the agent write free-form SQL on productionValid SQL can still answer the wrong question or exceed scopeExpose reviewed, typed queries with result contracts
Raise k to improve accuracyA bigger sample is still a sample, with more stale copiesUse the right store for exact questions
Let retrieved text override a database fieldEvidence starts acting as an instructionRecords win; log the conflict

Seven rules for vector and application data

  1. Use similarity search to find candidates, never to state facts about current business state.
  2. Answer totals, counts and status with exact queries on the system of record.
  3. Apply the requester's authority inside retrieval and inside every query.
  4. Give agents typed, reviewed queries, not raw tables.
  5. Record a receipt for every query: what ran, for whom, against which data, with what result.
  6. Link every chunk to its source record and version; collapse duplicates.
  7. When retrieved text and the record disagree, the record wins.

The result: candidates and truth, each in its place

Vector databases earned their place in agent architectures. They make unstructured knowledge usable, and nothing else finds the right passage in ten thousand contracts as well. The mistake is asking them to do a second job they were never designed for.

Agents that act on business data need both stores, each answering the questions it's built for: permission-aware retrieval for evidence, and typed, scoped, recorded queries for anything that must be exactly true right now. Put that split in the architecture rather than in the prompt, and the agent's answer about Acme becomes one you can check, repeat and defend.


Frequently asked questions

Can a vector database replace a relational database for AI agents?

Not for operational data. A vector database ranks content by similarity, which suits documents and evidence. Balances, order status, approvals and counts need transactions, current state, exact queries and record-level authorization, which belong to the application database.

Why do RAG agents get totals and counts wrong?

Because similarity search returns the top few matching chunks, not every matching record. A total built from those chunks misses records that weren't retrieved, includes stale or cancelled ones, and can't tell which copy of a record is current.

How do you stop an agent retrieving records a user can't see?

Apply the user's authorization before results reach the model: filter by tenant, scope and record-level permission inside retrieval and inside every query. Filtering the model's answer afterwards is too late, because the restricted content has already been read.

How does this work for agents we already run?

Route the agent's data calls through a governed runtime over MCP or HTTPS. Questions about current state go to typed, scoped queries with a receipt, document questions go to permission-aware retrieval, and both run with the authority of the person the agent acts for.

With Frozion

How Frozion gives agents both kinds of data access

Frozion keeps similarity search and operational truth in their proper places. Collections & Query Builder gives agents typed operational collections with join and result contracts, so totals, counts and status come from exact queries authored in SQL or visually, each with a query receipt. Context Store & Assembly puts a checked context package behind every action, and evidence never gives orders. Authorization combines roles, conditions, taxonomy scope, purpose and record-level checks, and every agent acts with the authority of the person it represents, never more.


Sources

  1. OWASP Top 10 for LLM Applications 2025Sensitive information disclosure and vector and embedding weaknesses in retrieval systems.
  2. OWASP LLM08:2025 Vector and Embedding WeaknessesCross-context leakage and weak access control in vector stores.
  3. NIST SP 800-162, Guide to Attribute Based Access ControlDecisions based on subject, object and environment attributes, per request.
  4. NIST SP 800-53 Rev. 5AC-3 access enforcement and AC-6 least privilege.
  5. IBM Cost of a Data Breach Report 202597% of organizations with an AI-related breach lacked proper AI access controls.
  6. NIST AI Risk Management Framework 1.0Validity, reliability and accountability of AI outputs.
More in Data & context

Data & context

Context assembly 2
Retrieval & data access 3
State, memory & features 2

Other topics

Pick up where you left off: