🚀 Now building SaaS & AI products for founders — book a demo →
✦ AI & RAG apps that understand your business data →
⇄ Multi-marketplace order & inventory automation →
🌍 20+ years of product engineering · US · EU · India →
← All posts
AI / Data

Ask your database in plain English: how natural-language-to-SQL works

Every company has data locked in a database and a queue of people waiting on an analyst to pull it. A natural-language-to-SQL layer removes that bottleneck: someone types a question in plain English, the system writes the query, runs it, and returns the answer in seconds. We built exactly this for querying any database in plain English, and as the engineering partner behind QoreAI's QoreCloud for dealerships.

It is not "send the question to an LLM"

A model that hasn't seen your schema will hallucinate table and column names. The trick is to make the model schema-aware: retrieve the relevant tables, columns, relationships and a few example rows, and supply them as context — RAG, but for your database structure rather than documents.

Safety is the whole game

Letting a model write SQL against production data sounds terrifying — and would be, without guardrails. The pattern that makes it safe:

-- generated from: "top 5 products by revenue this quarter"
SELECT p.name, SUM(oi.qty * oi.price) AS revenue
FROM order_items oi
JOIN products p ON p.id = oi.product_id
WHERE oi.created_at >= date_trunc('quarter', now())
GROUP BY p.name ORDER BY revenue DESC LIMIT 5;

Why it changes who can use data

When anyone can ask a question without knowing SQL or waiting on a report, data stops being a specialist resource and becomes something the whole team uses to make decisions. That shift — not the model — is the real product.

Talk to us about your AI project

← Building an AI knowledge assistant your support team will actually useWhat is RAG, and why your business data belongs in your AI →