Natural Language SQL: Ask Your Database in Plain English
The Data Access Problem
Your company sits on years of valuable data — customer records, sales figures, project timelines, inventory levels, employee metrics. This data holds answers to thousands of business questions. But accessing it requires SQL knowledge that most employees do not have. The result: data requests queue up at the IT department, analysts become bottlenecks, and decisions get made on gut feeling instead of data.
Natural Language to SQL bridges this gap. Instead of writing SELECT statements with JOINs, WHERE clauses, and GROUP BYs, users simply ask questions in plain language. The AI translates the question into a valid SQL query, executes it against your database, and presents the results in a human-readable format.
How It Works in Corpilus
The DB Reader module in Corpilus implements Natural Language SQL with multiple safety layers. First, you configure a read-only database connection — the system can never modify your data. Second, you select which tables and columns are accessible, creating a whitelist that the AI cannot bypass. Third, you provide natural language descriptions for each table and column, helping the AI understand your schema semantics.
When a user asks a question, the pipeline works as follows. The AI analyzes the question and identifies which tables are relevant. It generates a SQL query using only whitelisted tables and columns. The query is validated for safety — no writes, no schema modifications, no unreasonable complexity. The query executes against your database. Results are returned to the AI, which formats them into a clear, natural language answer with the option to show the underlying query.
Real-World Examples
A sales manager asks: 'What was our revenue by product category in Q4 2025?' The AI generates a query joining orders with products, filtering by date range, grouping by category, and summing revenue. Result: a clean table with categories and numbers, delivered in seconds.
A project lead asks: 'Which projects are over budget and behind schedule?' The AI queries the project management tables, compares actual vs planned budgets and timelines, and returns a prioritized list of at-risk projects with specific numbers.
An HR director asks: 'What is our average time-to-hire by department over the last 12 months?' The AI calculates the difference between job posting dates and hire dates, groups by department, and presents a clear comparison.
Safety and Governance
The biggest concern with natural language SQL is safety. What if someone asks for data they should not see? Corpilus addresses this at multiple levels. Table and column whitelisting means the AI physically cannot query restricted data. Row-Level Security inherited from your PostgreSQL database ensures tenant isolation. Query logging creates an audit trail of every question asked and every query executed. And role-based access can restrict which users can access the DB Reader feature at all.
Getting Maximum Value
The quality of natural language SQL depends heavily on how well you describe your schema. Invest time in writing clear, descriptive names and descriptions for your tables and columns. Instead of 'tbl_ord', describe it as 'Customer orders table containing order date, total amount, status, and shipping information.' The better the AI understands your schema, the more accurate its queries will be.