How We’re Using AI at DB Gurus: A Smarter Way to Build Queries

At DB Gurus, we’ve recently embraced an “AI First” approach to how we work. So naturally, when it came time to introduce AI features into our cloud database platform—creatively named TheDatabase — I turned to Copilot.*

After doing my research and writing up a detailed spec, I handed it off to one of our top developers, Mohsin, for review and implementation.

A few days later, he came back with an alternative. A better one. It was simpler—and in my experience, simple is always better. Not only was it more elegant, it would also be easier to implement.

We wanted to add a new icon to our summary screens (the ones that display lists of data). When clicked, this icon would open a text box where users could type—or dictate—natural language queries like:

“Show me the records that have X, Y, or Z.”

Mohsin’s Solution

Here’s what he proposed:

  1. Pass the database schema to Copilot so it understands the structure of the data.
  2. Send the user’s query along with a few well-crafted prompts.
  3. Copilot returns the SQL needed to fetch the data.
  4. Display the results in the UI.

To make this work smoothly, the table and column names need to be logical and intuitive. That way, the AI can better understand the structure and relationships in the database.

Our Twist: A Highly Configurable Schema

This is where things got interesting.

TheDatabase is designed to be extremely flexible. Users can add or modify tables and columns in real time—without needing structural changes to the database. As a result, all user data is stored in a single table, with metadata used to interpret and display it.

To help Copilot make sense of this, we generate a set of database views with clear, human-friendly names. These views serve as our schema when interacting with the AI.

AI DB

Practical Tips for AI-Friendly Schema Design

If you’re thinking about doing something similar, here are a few tips that might help:

  • Match table names to the UI. If the screen says “Clients,” the table should be named Client or Clients—users will likely say “Show me all clients that…”
  • Use simple primary keys. Preferably something like ClientID. Avoid composite keys.
  • Keep foreign key field names consistent. They should match the primary key they reference (e.g., ClientID in both tables).
  • Use descriptive field names. Ideally, these should match the labels shown in the UI.

That’s the theory. In my next article, I’ll dive into the real-world challenges we faced—and how we solved them.

Note: At DB Gurus, we use Copilot because it integrates seamlessly with the Microsoft ecosystem and can securely access company-specific data. ChatGPT, on the other hand, is a more general-purpose AI tool.

Next Steps

To read about how we are allowing users to use natural language to create queries in our database platform see How We’re Using AI at DB Gurus: A Smarter Way to Build Queries

To have a chat about what we can do for you please book a call with our friendly team.

#Copilot #ChatGPT #AI #Database #Development