Step-by-Step Tutorials

Your First AI-Powered Query

Your First AI-Powered Query

The AI Chat Assistant makes database exploration accessible to everyone, regardless of SQL knowledge. This tutorial walks you through your first AI-powered query, from opening the Chat page to understanding results. By the end, you'll be comfortable asking questions in natural language and interpreting what the AI tells you about your data.

What You'll Learn

By the end of this tutorial, you'll be able to:

  • Navigate to the Chat interface
  • Understand the Chat page layout
  • Configure an AI provider (simplified approach)
  • Ask your first simple question
  • Interpret AI responses
  • Request data from specific tables
  • View the SQL code behind AI responses
  • Handle and learn from errors
  • Ask follow-up questions to refine results

Prerequisites

Before starting, make sure you have:

  • WhoDB connected to a database with data
  • An AI provider configured (OpenAI, Anthropic, Gemini, Ollama, or LM Studio)
  • Basic familiarity with your database structure (what tables exist)

Step 1: Opening the Chat Page

After connecting to your database, navigate to the Chat page:

Chat Initial Page

The Chat page is your gateway to natural language database interaction. You'll notice several elements:

AI Provider Dropdown: At the top left, shows your current AI provider (OpenAI, Anthropic, Gemini, Ollama, or LM Studio).

AI Model Dropdown: Next to the provider, displays the specific model being used, fetched from your provider.

Chat Interface: The main area where your conversation with the AI will appear.

Input Box: At the bottom, where you type your questions.

Example Prompts: Helpful suggestions to get you started with common questions.

Step 2: Understanding Your AI Configuration

Before asking questions, let's verify your AI configuration. Click the AI Provider dropdown to see available providers:

AI Provider Dropdown

You should see at least one configured provider:

  • OpenAI: Cloud-based, fast and accurate
  • Anthropic: Cloud-based, excellent for complex queries
  • Gemini: Cloud-based, added with a Gemini API / AI Studio key
  • Ollama: Local, privacy-focused, detected automatically when running
  • LM Studio: Local, privacy-focused, detected automatically when running

Select your preferred provider if it's not already active.

Next, click the AI Model dropdown to see available models:

AI Model Dropdown

Different models offer different trade-offs:

  • More capable models: Better accuracy, slightly slower
  • Faster models: Quick responses, good for simple queries
  • Local models (via Ollama or LM Studio): Complete privacy, speed varies by hardware

The model list is fetched from your provider, so it always reflects your provider's current lineup.

Step 3: Using Example Prompts

WhoDB provides example prompts to help you understand what kinds of questions you can ask:

Example Prompts

These examples demonstrate different query types:

  • List queries: "Show me all users"
  • Filtered queries: "Find products with price greater than 100"
  • Aggregation queries: "Count orders by status"
  • Date-based queries: "Show orders from last month"

Click any example prompt to see how it works. For this tutorial, let's start with something even simpler.

Step 4: Asking Your First Question

Let's start with the most basic question possible. In the input box at the bottom, type:

What tables exist in this database?

Press Enter or click the send button.

Within a few seconds, you'll receive a response:

Simple Text Response

The AI will list all tables in your database, providing a clear overview of your data structure. This simple question demonstrates the AI's awareness of your database schema.

What just happened?

  1. Your question was sent to the AI provider
  2. The AI analyzed your database structure
  3. It generated an appropriate query (in this case, a schema query)
  4. The results were formatted into a readable response

Step 5: Retrieving Actual Data

Now let's ask for actual data. Type this question:

Show me all users

Press Enter and watch what happens:

SQL Query Results

The AI understands you want data from the users table and presents results in an interactive table. You'll see:

Column Headers: The fields from your users table (id, name, email, etc.)

Data Rows: Actual user records from your database

Pagination Controls: If there are many users, results are paginated for easy browsing

Interactive Features: You can scroll, sort columns, and explore the data just like in the Data view

Step 6: Viewing the SQL Code

Want to see what SQL query the AI generated? Click the "View Code" or code toggle button above the results:

SQL Code View

You'll see the actual SQL query that was executed:

sql

SELECT * FROM users;

This is valuable for several reasons:

  • Learning SQL: See how natural language translates to SQL syntax
  • Verification: Confirm the AI understood your question correctly
  • Refinement: Copy and modify queries in the Scratchpad if needed
  • Debugging: Understand what went wrong if results aren't what you expected

Step 7: Handling Errors Gracefully

Not all questions succeed on the first try. Let's see what happens when something goes wrong. Try asking:

Show me all customers from the products table

This question has a logical inconsistency—products tables don't typically have customer data:

Error Message

When errors occur, the AI provides helpful feedback:

  • What went wrong: Clear explanation of the issue
  • Why it failed: Context about the error
  • How to fix it: Suggestions for rephrasing or correcting the query

Common error scenarios:

  • Ambiguous questions: "Show me the data" (which table?)
  • Invalid operations: Asking for columns that don't exist
  • Logic errors: Combining incompatible filters
  • Permission issues: Requesting operations your database user can't perform

Step 8: Asking Follow-Up Questions

The real power of the AI assistant comes from conversation. The AI remembers your previous questions, enabling natural follow-ups.

After asking "Show me all users", try this follow-up:

How many are there?

The AI understands "there" refers to users from your previous question:

Aggregation Query

The response shows a count of total users. Notice you didn't need to repeat "users"—the AI maintained context from your conversation.

More follow-up examples:

After viewing users:

  • "Show only active ones" (filters to active users)
  • "Sort by creation date" (reorders results)
  • "What about users from last month?" (adds date filter)

Each question builds on the previous context, creating a natural exploration flow.

Step 9: Filtering and Refining Results

Let's practice refining queries with specific criteria. Ask:

Show me users created in the last 7 days

The AI generates a query with date filtering and displays recent users. The results are automatically filtered to match your timeframe criteria.

Try more refined queries:

  • "Show users with gmail addresses"
  • "Find users who haven't logged in for 30 days"
  • "Show the 10 most recent signups"

Each question demonstrates different filtering capabilities:

  • Pattern matching: Email domain filtering
  • Date calculations: Relative time periods
  • Sorting and limiting: Top N results

Step 10: Understanding Confirmations for Changes

The AI assistant is safe by design. When you ask to modify data, it requires explicit confirmation.

Try asking:

Delete the oldest user account

Instead of immediately deleting data, you'll see:

Action Confirmation

The AI shows:

  • What will happen: Clear description of the action
  • Which data will be affected: Preview of rows to be changed
  • Confirmation required: Explicit prompt to proceed or cancel

This safety feature prevents accidental data loss. The chat displays inline Confirm and Cancel buttons with the pending action — click Confirm to execute it, or Cancel to abort.

After confirming:

Action Executed

The AI confirms the action was executed and shows how many rows were affected.

Step 11: Building a Multi-Message Conversation

Let's see how a real exploration session might flow with multiple related questions:

Multiple Messages

A typical conversation might look like:

You: "What tables are related to orders?"

AI: Lists tables with foreign key relationships to orders

You: "Show me the most recent 5 orders"

AI: Displays last 5 orders with all columns

You: "What's the total value of these orders?"

AI: Calculates and shows the sum

You: "Show me the customer details for these orders"

AI: Joins orders with customers table, showing combined data

This conversation demonstrates:

  • Context preservation: Each question builds on previous ones
  • Progressive refinement: Starting broad, then getting specific
  • Natural flow: Questions you'd naturally ask when exploring data

Step 12: Moving Queries to Scratchpad

When you find a useful query, you might want to save it or modify it further. Click the "Move to Scratchpad" option on any AI response:

Move to Scratchpad Dialog

A dialog appears where you choose the destination:

  • Select an existing Scratchpad page, or
  • Enter a name to create a new page

After moving to Scratchpad, you can:

  • Edit and refine the SQL manually
  • Save the query for future use
  • Combine it with other queries
  • Execute it repeatedly with modifications

This bridges AI exploration with traditional SQL workflow, giving you the best of both worlds.

Step 13: Starting a New Chat

Each conversation session maintains its own context. When you want to start fresh, click the "New Chat" button:

New Chat Button

This clears the conversation history and starts a new session. Use this when:

  • Switching to a completely different topic
  • Context from previous questions is confusing the AI
  • You want a clean slate for a new analysis

Best Practices for AI Queries

Common First-Time Questions

When starting with the AI assistant, these questions are particularly useful:

Schema Exploration
  • "What tables exist?"
  • "Describe the users table"
  • "How are orders and customers related?"
  • "Show me all column names in products"
Data Sampling
  • "Show me 10 sample rows from users"
  • "What does the data in products look like?"
  • "Show me a few examples from orders"
Data Validation
  • "Are there any NULL values in the email column?"
  • "How many users have incomplete profiles?"
  • "Find duplicate email addresses"
Basic Statistics
  • "How many total users are there?"
  • "What's the average order value?"
  • "Count products by category"

Troubleshooting Common Issues

What You Learned

In this tutorial, you successfully:

  • Navigated to the Chat interface
  • Understood the Chat page layout and controls
  • Verified your AI provider configuration
  • Asked questions in natural language
  • Retrieved data without writing SQL
  • Viewed and understood generated SQL code
  • Handled errors and learned from them
  • Used conversation context for follow-up questions
  • Applied filters and refinements naturally
  • Understood safety confirmations for data changes
  • Built multi-turn conversations
  • Moved useful queries to Scratchpad

Next Steps

Now that you're comfortable with basic AI queries, explore more advanced capabilities:

Querying Data

Learn advanced querying techniques with joins and aggregations

Modifying Data

Safely update, insert, and delete records using natural language

Conversation Features

Master context management and multi-turn dialogues

Data Exploration Workflow

Combine AI queries with traditional data views

Congratulations

You've taken your first steps into AI-powered database interaction. The skills you learned here—asking clear questions, interpreting responses, refining through conversation—will serve you well as you explore more complex queries and analysis tasks.

Remember: the AI assistant is a tool to augment your capabilities, not replace your judgment. Use it to explore faster, learn SQL patterns, and focus on insights rather than syntax. With practice, you'll develop intuition about how to phrase questions effectively and when to leverage AI assistance versus traditional SQL.