0% found this document useful (0 votes)
5 views3 pages

SQL Lab Activities

This document is a lab activity sheet for a SQL reading lab, focusing on evaluating AI-generated SQL queries using Microsoft Access. It includes steps for setting up the environment, conducting experiments with and without schema, and reflecting on the results. Additionally, it emphasizes the importance of understanding SQL queries in plain language and verifying AI outputs against actual data.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

SQL Lab Activities

This document is a lab activity sheet for a SQL reading lab, focusing on evaluating AI-generated SQL queries using Microsoft Access. It includes steps for setting up the environment, conducting experiments with and without schema, and reflecting on the results. Additionally, it emphasizes the importance of understanding SQL queries in plain language and verifying AI outputs against actual data.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MAN456 · DATA MANAGEMENT SQL Reading Lab · Activity Sheet · p.

1/3

READING SQL · LAB ACTIVITY

Can you trust what AI writes?


Today you will ask AI for SQL, run it in Access, and judge it line by line.
Keep your cheat sheet open at all times.

BEFORE YOU START · setup

1 Open Microsoft Access and load the Northwind 2.0 Starter database (File → New → search 'Northwind' → Starter
Edition).
2 Open Claude ([Link]) in your browser. Use a fresh conversation for each activity.
3 In Access, click Database Tools → Relationships to see the table structure. Note the table names and key columns.
4 To run SQL: Create → Query Design → close the table picker → Home → View → SQL View. Type your query, then
Run (red ! icon).

Schema-first Prompting 20 min


1 Goal: Show that AI's output quality depends on the context you give it.

ROUND 1 — no schema given


Open a fresh conversation with Claude. Send this exact message (do NOT paste any schema):

"Write a SQL query for the Northwind database that shows the names
and cities of all customers from Germany, sorted by name."

1 Copy the SQL Claude returns. Paste it into Access SQL View and try to run it.

2 If it fails: write down the error message. Which column or table did Claude invent?

3 If it runs: do the results look correct? How would you check?

ROUND 2 — with schema


1 Open a NEW conversation in Claude. First message: paste the schema (table and column names) for the Customers table.
Read these from Design View (right-click table → Design View).

2 Then send the SAME question as Round 1.

3 Run the new SQL in Access. Compare to Round 1.

REFLECT
• Did Round 1's SQL run correctly? If not, what did Claude assume?
• Which column or table names changed between Round 1 and Round 2?
• In your future job, when will you need this habit of giving context?

Yalova University · Faculty of Business · MAN456 Data Management


MAN456 · DATA MANAGEMENT SQL Reading Lab · Activity Sheet · p. 2/3

Explain This Query to Your Boss 20 min


2 Goal: Practice reading SQL — translate code into plain English a manager can understand.

Below is a SQL query. Your job is to figure out what it does, without using any technical SQL words.

SELECT Country, COUNT(*) AS HowMany


FROM Customers
WHERE City LIKE 'M%' OR City LIKE 'P%'
GROUP BY Country
ORDER BY HowMany DESC, Country;

1 Read the query in the order from your cheat sheet (FROM → WHERE → GROUP BY → SELECT → ORDER BY).

2 Run it in Access. Look at the result.

3 Now write 1 or 2 sentences explaining what this query answers, as if you were emailing a sales manager. RULES: no SQL
words (no 'GROUP BY', no 'WHERE clause', no 'COUNT'). Use everyday business language only. Write your sentences
below:

4 Now ask Claude to explain the SAME query line by line. Compare to your version. Is your explanation clearer for a
non-technical reader, or is Claude's? Underline anything Claude got wrong or confusing.

REFLECT
• Which keyword was the trickiest to explain in plain English?
• Did Claude's explanation match what the query actually does?
• Why is reading SQL still useful when AI can write it for you?

Yalova University · Faculty of Business · MAN456 Data Management


MAN456 · DATA MANAGEMENT SQL Reading Lab · Activity Sheet · p. 3/3

Verify the Answer · Catch the Trap 20 min


3 Goal: Check AI's number against reality, then find what is wrong with a query that LOOKS reasonable.

PART A — Business answer vs. query answer


1 Ask Claude (with the schema): "Show me the number of customers we have in each country, sorted from most to fewest."

2 Run the SQL. Note the country at the top and its count.

3 Now manually verify: open the Customers table directly. Filter or sort by Country. Count the rows for the top country by
hand. Does it match Claude's number?

4 If they match: good. If they don't: WHY might they differ? (Hint: NULLs, what counts as a 'customer', or a hidden filter.)

PART B — The trap query


The query below LOOKS reasonable. Read it carefully before you run it.

SELECT Country, City, COUNT(*) AS NumCustomers


FROM Customers
GROUP BY Country
ORDER BY NumCustomers DESC;

1 Run it. What happens? (Either it errors out, or it returns weird-looking data — describe what you see.)

2 Re-read the GROUP BY rule on your cheat sheet. Why is this query wrong?

3 Fix it TWO different ways: (a) add City to GROUP BY, (b) remove City from SELECT. Run both. Are the results the same?
What is the business meaning of each?

REFLECT
• What is the single most important habit when using AI for SQL?
• Name one mistake AI made today that surprised you.
• Next time you ask an AI for code, what will you do differently?

★ BONUS — if you finish early


• Same prompt, two conversations: ask Claude the same question in two separate conversations. Do you get IDENTICAL SQL?
If not, which is better and why?
• Self-review: ask Claude to write a query, then in the same chat ask "Find any bugs in your previous query." Does it admit any?
• Tighter spec: replace a vague request like "top customers" with three precise definitions (most orders / highest total / most
recent activity). Get a query for each. Are the answers the same?

Yalova University · Faculty of Business · MAN456 Data Management

You might also like