SQL practice: How a Database Thinks

Introduction 3 · 6 questions · free to solve

  1. Question 1 · easy

    Which column in orders is its primary key? Which columns are foreign keys?

    Solve it in your browser
  2. Question 2 · easy

    order_items has a column called unit_price, and so does products. Why store the price twice instead of always looking it up in products?

    Solve it in your browser
  3. Question 3 · medium

    If customer_id 3 is deleted from customers, what should happen to their orders? What does the foreign key do about it?

    Solve it in your browser
  4. Question 4 · medium

    Explain in one sentence why "every query returns a table" makes subqueries possible.

    Solve it in your browser
  5. Question 5 · hard

    Read this aloud in plain English: SELECT city FROM customers WHERE customer_type = 'Dealer';

    Solve it in your browser
  6. Question 6 · hard

    employees.manager_id points at employees.employee_id — the same table. What real-world fact is that recording?

    Solve it in your browser

These questions are free.

Make a free account to solve them, with instant checking and an AI tutor for hints.

Start free