Skip to content
/Chapter 17 · Guided Playground Missions
Lesson 17.1·garden_shop
Lesson 17.1

SQL Playground Mission: Map a Dataset Before Querying

Start freeform SQL work by building a quick map of table sizes.

Before writing a report on an unfamiliar dataset, map the tables. A row-count inventory tells you which tables are small lookup tables, which tables hold transactional detail, and where a join might multiply rows.

This mission uses UNION ALL to stack one small count query per table. It is the same habit you can use in the playground before exploring your own CSV or Parquet upload.

Pattern
select 'first_table' as table_name, count(*) as rows from first_table
union all
select 'second_table', count(*) from second_table
order by rows desc, table_name
Schema · Garden ShopView dataset schema6 tables
Table · customers

One row per customer. Some customers have no phone on file.

9 columns · 20 rows
customer_id intfirst_name textlast_name textemail textphone textcity textstate textsignup_date dateis_active bool
Table · products

One row per product, with price, cost, and inventory levels.

9 columns · 24 rows
product_id intproduct_name textcategory_id intsupplier_id intprice decimalcost decimalquantity_on_hand intreorder_level intdiscontinued bool
Table · categories

Lookup table of product categories.

2 columns · 8 rows
category_id intcategory_name text
Table · orders

One row per order. Unshipped orders have a null shipped_date.

6 columns · 24 rows
order_id intcustomer_id intorder_date dateshipped_date datestatus textcoupon_code text
Table · order_items

One row per line item within an order.

5 columns · 48 rows
order_item_id intorder_id intproduct_id intquantity intunit_price decimal
Table · suppliers

One row per supplier. Some suppliers have no contact email.

4 columns · 6 rows
supplier_id intsupplier_name textcontact_email textstate text
Your task

Return a table inventory for Garden Shop. The result should havetable_name and rows, covering customers, products, categories, orders, order_items, and suppliers. Sort by row count descending, then table name.

SQL Workbench
query.sqlgarden_shop · SQL engine loading
⌘↵ to run
·
Expected answer
  • Columns: table_name, rows.
  • Rows: one per Garden Shop table (6 rows).
  • order_items is largest with 48 rows; suppliers is smallest with 6 rows.