Skip to content

Start with the Data, Not the Vector Database

By Maksym Kuzmitskyi
6 min read
Start with the Data, Not the Vector Database

Start with the Data, Not the Vector Database

Someone asks whether release R-42 was approved. The assistant searches a handbook and explains how approval normally works.

The explanation may be accurate. It still hasn't answered whether that release was approved.

This is the point where I would resist improving the embedding model. A policy document describes a rule. A release record describes an instance. A history of approval events describes how that instance changed. Better similarity search doesn't turn those into the same source.

Our fictional documentation assistant is about to gain retrieval. Before giving it a search index, I want to decide which questions should be searches at all.

The shape of the question matters

Structured data has explicit fields and relationships: a release identifier, status, owner and approval timestamp. SQL, Structured Query Language, lets an application ask precise questions of relational tables.

Unstructured data, such as a prose policy, has meaning that doesn't fit neatly into one fixed row shape. Semi-structured data sits between those extremes: a document might have headings, front matter or JSON fields around a free-form body.

Those labels aren't quality rankings. A well-structured table can be stale. A paragraph can be authoritative. The distinction helps choose an access path, not decide what to believe.

An event stream adds another dimension: time and sequence. Current status and the events that produced it can answer different questions. Asking what happened after an approval is not the same as reading the final status field.

A model doesn't need to invent every query

For a known record lookup, I would begin with a fixed, parameterized query rather than unrestricted text-to-SQL. Parameterization keeps user values separate from the query structure.

The node-postgres query documentation describes that separation and notes that parameters apply to values, not table or column identifiers. I would not turn a model-suggested table name into a trusted identifier.

Here is an application-level planner over already-validated requests. The tenant identifies the authorized customer or workspace and comes from the authenticated backend, not from a model choosing its own scope:

type Lookup = | { kind: 'record'; id: string } | { kind: 'document'; question: string }; function planLookup(tenantId: string, lookup: Lookup) { if (!tenantId.trim()) throw new Error('Missing tenant'); if (lookup.kind === 'record') { if (!lookup.id.trim()) throw new Error('Missing release identifier'); return { kind: 'sql' as const, query: { text: 'SELECT id, state FROM release_records WHERE tenant_id = $1 AND id = $2', values: [tenantId, lookup.id.trim()], }, }; } if (!lookup.question.trim()) throw new Error('Missing question'); return { kind: 'document-search' as const, tenantId, question: lookup.question.trim(), }; }

This constructs a plan; it doesn't connect to a database. The SQL assumes a release_records table with the named fields. Authorization for the operation, connection configuration, timeouts and result validation belong to the execution adapter.

The union distinguishes two requests the product already understands. If a model helps classify a natural-language request into that union, its classification still needs validation. An ambiguous "was it approved?" should not silently become a lookup for whichever release was mentioned most recently in an unrelated context.

Check that values stay values

These are offline fixtures for query construction, not evidence that a database returned the right release:

const recordPlan = planLookup('workspace-a', { kind: 'record', id: "release'42" }); const policyPlan = planLookup('workspace-a', { kind: 'document', question: 'When does production require human approval?', });

The quote in the identifier stays in the values array. It doesn't become part of the SQL text. The policy question becomes a document-search request instead of being forced into a status field.

This is a narrow but useful invariant. It doesn't prove the caller was entitled to inspect the release. A tenant parameter limits the query only if trusted execution supplies it and all relevant paths enforce the same boundary.

For event history, I would add a separate bounded operation with an explicit time range and stable ordering. I wouldn't overload the record lookup to return an unlimited log because the model might find it useful.

Documents arrive with their own problems

A PDF can contain selectable text, scanned pages, tables, diagrams or several of those at once. OCR, optical character recognition, extracts text from images; it can also misread punctuation, identifiers and column alignment.

A table converted into plain text may lose which value belongs to which heading. A code example may depend on its surrounding explanation. A screenshot may show a state that the current text no longer describes.

I would preserve source identity, revision and location during extraction. An answer referring to a page or section should be traceable to what was actually extracted, not just to the filename somewhere upstream.

Multimodal retrieval uses information such as images or audio as well as text. It can be useful when the evidence genuinely lives in those forms. It is not a reason to describe a lossy text extraction as the complete original document.

Freshness and authority come before clever ranking

A policy search should know whether it is searching current rules, historical rules or both. A status lookup should know whether its source is authoritative or a delayed reporting copy.

If the source is unavailable, the application should preserve that uncertainty. A nearby document about approval isn't a fallback source for the live approval state unless the product explicitly defines that relationship.

For our assistant, I would keep the retrieved evidence labelled by source type. A generated answer can then distinguish "the policy requires approval" from "the release record says approval was recorded." Combining those claims without their origins makes the explanation sound more complete than the evidence.

The first useful architecture may therefore be one fixed record query and one bounded document-search function. Neither needs a vector database on day one.

When document wording becomes varied enough that exact terms miss useful material, embeddings become worth discussing. They give us a way to compare learned representations of content. Before trusting the comparison, I want to understand what those numbers represent and what they don't.

Which question in your assistant currently gets answered from a document when it really needs a record? That mismatch is worth fixing before changing the search stack.

A note from the author

I’m Maksym Kuzmitskyi, a senior software developer working mainly with React and TypeScript. I build frontend applications and design workflows for working with AI in software delivery. If this article connects with something you’re working on, I’d love to hear from you.

Telegram

More than a blog post

I share frontend news and the reasoning behind it throughout the day. Pick the language that feels natural to you.

Need to discuss your project? Get in touch.