<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vincenzo Nudo</title>
    <description>The latest articles on DEV Community by Vincenzo Nudo (@vincenzo_nudo_842cddd9973).</description>
    <link>https://dev.to/vincenzo_nudo_842cddd9973</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3827170%2Fe09d1dcc-c40d-4fcf-bf16-f8ea0d1b6090.png</url>
      <title>DEV Community: Vincenzo Nudo</title>
      <link>https://dev.to/vincenzo_nudo_842cddd9973</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vincenzo_nudo_842cddd9973"/>
    <language>en</language>
    <item>
      <title>How I turned approved SQL into governed business KPIs</title>
      <dc:creator>Vincenzo Nudo</dc:creator>
      <pubDate>Mon, 16 Mar 2026 15:36:32 +0000</pubDate>
      <link>https://dev.to/vincenzo_nudo_842cddd9973/how-i-turned-approved-sql-into-governed-business-kpis-4673</link>
      <guid>https://dev.to/vincenzo_nudo_842cddd9973/how-i-turned-approved-sql-into-governed-business-kpis-4673</guid>
      <description>&lt;p&gt;In a lot of companies, executives and business teams want answers from company data, but they do not know SQL.&lt;/p&gt;

&lt;p&gt;That part is obvious.&lt;/p&gt;

&lt;p&gt;What is less obvious is that SQL is not the real problem.&lt;/p&gt;

&lt;p&gt;The real problem is this:&lt;/p&gt;

&lt;p&gt;How do you let non-technical users ask business questions about company data without exposing raw SQL, direct database access, or completely uncontrolled AI generated queries?&lt;/p&gt;

&lt;p&gt;That was the problem I wanted to solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  The naive solution looks attractive
&lt;/h2&gt;

&lt;p&gt;The first idea is always the same:&lt;/p&gt;

&lt;p&gt;Connect an AI assistant directly to the database and let people ask questions in natural language.&lt;/p&gt;

&lt;p&gt;At first, this sounds great.&lt;/p&gt;

&lt;p&gt;In practice, it creates a different set of problems:&lt;/p&gt;

&lt;p&gt;• the business definition of a metric is not stable&lt;br&gt;&lt;br&gt;
• different prompts may produce different SQL for the same question&lt;br&gt;&lt;br&gt;
• there is no strong boundary between approved and unapproved logic&lt;br&gt;&lt;br&gt;
• scheduling, monitoring, and delivery workflows are still missing&lt;br&gt;&lt;br&gt;
• auditability becomes weak very quickly&lt;br&gt;&lt;br&gt;
• private environments become painful to manage  &lt;/p&gt;

&lt;p&gt;In other words, query generation is only one small part of the problem.&lt;/p&gt;

&lt;p&gt;The harder part is making the answers reliable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern I ended up using
&lt;/h2&gt;

&lt;p&gt;Instead of letting AI write arbitrary SQL for business users, I flipped the model.&lt;/p&gt;

&lt;p&gt;The system starts from real SQL written and approved by analysts.&lt;/p&gt;

&lt;p&gt;The flow looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An analyst writes a real SQL query.&lt;/li&gt;
&lt;li&gt;They define only the minimal input parameters needed for the business question.&lt;/li&gt;
&lt;li&gt;That query becomes a governed KPI.&lt;/li&gt;
&lt;li&gt;The KPI can contain multiple query variants.&lt;/li&gt;
&lt;li&gt;Business users never see SQL.&lt;/li&gt;
&lt;li&gt;They only see KPI cards and ask follow-up questions in plain language.&lt;/li&gt;
&lt;li&gt;AI maps the question to the right KPI variant.&lt;/li&gt;
&lt;li&gt;The backend executes only approved query paths.&lt;/li&gt;
&lt;li&gt;The UI renders the result as a scalar, a short list, or a chart.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That design changes everything.&lt;/p&gt;

&lt;p&gt;The SQL remains controlled.&lt;/p&gt;

&lt;p&gt;The business experience becomes flexible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why query variants matter
&lt;/h2&gt;

&lt;p&gt;This was one of the most important parts of the design.&lt;/p&gt;

&lt;p&gt;A single KPI often needs more than one query behind it.&lt;/p&gt;

&lt;p&gt;For example, imagine a fintech KPI about money movement.&lt;/p&gt;

&lt;p&gt;The same KPI may need:&lt;/p&gt;

&lt;p&gt;• a default comparison variant for today versus yesterday&lt;br&gt;&lt;br&gt;
• a trend variant for a daily bar chart this week&lt;br&gt;&lt;br&gt;
• a breakdown variant for operational exceptions like refunds or failed payments  &lt;/p&gt;

&lt;p&gt;From the business user’s point of view, this still feels like one KPI.&lt;/p&gt;

&lt;p&gt;From the backend point of view, it is a governed set of approved query variants.&lt;/p&gt;

&lt;p&gt;That means the user can ask:&lt;/p&gt;

&lt;p&gt;• How are we doing versus yesterday&lt;br&gt;&lt;br&gt;
• Show the daily trend this week&lt;br&gt;&lt;br&gt;
• Are refunds rising  &lt;/p&gt;

&lt;p&gt;But the system is not improvising SQL every time.&lt;/p&gt;

&lt;p&gt;It is resolving the question to a predefined execution path.&lt;/p&gt;

&lt;p&gt;That is the difference between flexibility and chaos.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the AI actually does
&lt;/h2&gt;

&lt;p&gt;This is the part I think many teams get wrong.&lt;/p&gt;

&lt;p&gt;In my flow, AI does not generate arbitrary SQL against the database.&lt;/p&gt;

&lt;p&gt;Its role is narrower and much more useful:&lt;/p&gt;

&lt;p&gt;• interpret the user’s question&lt;br&gt;&lt;br&gt;
• map it to the correct KPI&lt;br&gt;&lt;br&gt;
• select the correct query variant&lt;br&gt;&lt;br&gt;
• resolve the right time context and parameters&lt;br&gt;&lt;br&gt;
• explain the result in business language  &lt;/p&gt;

&lt;p&gt;So the AI is acting as a language and intent layer, not as an unrestricted database operator.&lt;/p&gt;

&lt;p&gt;That matters because it gives business users a natural interface without giving up control, auditability, or execution safety.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this works better for business users
&lt;/h2&gt;

&lt;p&gt;Business users do not want to think about joins, schemas, or prompt engineering.&lt;/p&gt;

&lt;p&gt;They want answers like:&lt;/p&gt;

&lt;p&gt;• How did onboarding perform last week&lt;br&gt;&lt;br&gt;
• Show daily wires and P2P transfers this week&lt;br&gt;&lt;br&gt;
• Are failed payments increasing  &lt;/p&gt;

&lt;p&gt;They also want charts, lists, and short explanations.&lt;/p&gt;

&lt;p&gt;If the underlying SQL is already approved and versioned, you can give them that experience safely.&lt;/p&gt;

&lt;p&gt;The UI becomes simple because the backend is strict.&lt;/p&gt;

&lt;p&gt;That is a much better tradeoff than giving everyone direct AI to database access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execution still matters
&lt;/h2&gt;

&lt;p&gt;Even with this model, execution is still the real backbone.&lt;/p&gt;

&lt;p&gt;In my case, query execution, scheduling, and monitoring all follow the same deployment model.&lt;/p&gt;

&lt;p&gt;They can run:&lt;/p&gt;

&lt;p&gt;• in the cloud&lt;br&gt;&lt;br&gt;
• or on-prem through a dedicated installed agent  &lt;/p&gt;

&lt;p&gt;In general, on-prem is the preferable setup for sensitive environments, because the data never needs to be exposed outside the customer environment.&lt;/p&gt;

&lt;p&gt;The platform orchestrates the workflow, but execution stays close to the database.&lt;/p&gt;

&lt;p&gt;That turned out to be a very important distinction.&lt;/p&gt;

&lt;p&gt;A lot of teams do not just need answers.&lt;/p&gt;

&lt;p&gt;They need answers without opening up their data environment too much.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this unlocked
&lt;/h2&gt;

&lt;p&gt;This approach gave me a few things at the same time:&lt;/p&gt;

&lt;p&gt;• business users can ask follow-up questions in plain language&lt;br&gt;&lt;br&gt;
• analysts still control business logic&lt;br&gt;&lt;br&gt;
• the results stay tied to approved SQL&lt;br&gt;&lt;br&gt;
• charts and tables stay consistent with the same KPI definition&lt;br&gt;&lt;br&gt;
• scheduling and monitoring remain part of the same operational system&lt;br&gt;&lt;br&gt;
• cloud and on-prem execution both fit naturally into the model  &lt;/p&gt;

&lt;p&gt;So instead of treating natural language as a replacement for data workflows, I ended up using it as an access layer on top of governed workflows.&lt;/p&gt;

&lt;p&gt;That feels much more robust.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;I think a lot of teams are focusing on the wrong question.&lt;/p&gt;

&lt;p&gt;The question is not:&lt;/p&gt;

&lt;p&gt;Can AI generate SQL&lt;/p&gt;

&lt;p&gt;The more important question is:&lt;/p&gt;

&lt;p&gt;How much execution freedom should AI have around company data&lt;/p&gt;

&lt;p&gt;For business-facing analytics, I have become convinced that natural language works best when the SQL underneath is already approved, versioned, and operationally controlled.&lt;/p&gt;

&lt;p&gt;The hard part is not letting AI write SQL.&lt;/p&gt;

&lt;p&gt;The hard part is making business answers reliable.&lt;/p&gt;

&lt;p&gt;I’m building this approach in DataPilot, where approved SQL becomes governed business KPIs and business users can ask follow-up questions without touching raw SQL.&lt;/p&gt;

&lt;p&gt;If you want to see the product context behind this model, it’s here:&lt;br&gt;
&lt;a href="https://getdatapilot.com/product/business-kpis" rel="noopener noreferrer"&gt;https://getdatapilot.com/product/business-kpis&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>analytics</category>
      <category>data</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
