PartiQL: set up the sample tables

View .md

Every example in the dialect series queries one of three sample tables — stage.Users, stage.Outbox, stage.Orders — and the data is built so the queries the pages print return the rows the pages show. You don't need any of it to read the series (the in-page playgrounds run right where they are), but to type along in the studio you want these tables seeded first. Both paths take a couple of minutes: import the ready-made files into DynoStudio (no AWS account), or stand up a free local DynamoDB and load everything with one command.

You'll learn
  • Create the three stage.* tables — all keyed pk (string) + sk (string), on-demand
  • Load the 2,595-item sample, by importing into DynoStudio or seeding DynamoDB Local
  • Know which indexes ship with the data and which ones the series has you create yourself
  • Confirm the load with a single cheap query

Get the files

One download covers both paths: the bundle below holds the three data files, the three table definitions, the local seed script, and the dataset README. Prefer single files? Each one is listed after it.

Download

Path A — Import into DynoStudio

1. Create the tables. In DynoStudio, create each table with partition key pk (String) and sort key sk (String), billed on-demand — or run the statements in the query box. CREATE TABLE is a DynoStudio dialect surface (DynamoDB's own PartiQL has no DDL); the "Executes as" strip shows each CreateTable call before it runs:

sql
CREATE TABLE "stage.Users" (  PARTITION KEY pk STRING,  SORT KEY sk STRING) WITH BILLING = ON_DEMAND;CREATE TABLE "stage.Outbox" (  PARTITION KEY pk STRING,  SORT KEY sk STRING) WITH BILLING = ON_DEMAND;CREATE TABLE "stage.Orders" (  PARTITION KEY pk STRING,  SORT KEY sk STRING) WITH BILLING = ON_DEMAND;

2. Add the ByOrg index — the series' first GSI read uses it, and on this path it doesn't exist yet:

sql
CREATE GLOBAL INDEX "ByOrg" ON "stage.Users"  PARTITION KEY (OrgId)  PROJECT ALL

3. Import the data. Open each table, choose Import from CSV & JSON, pick its .ddb.json file, and review the key-aware preview before it writes. Import order doesn't matter.

Path B — Run it locally with DynamoDB Local

Prefer your own endpoint, offline and free? Stand up DynamoDB Local and let the seed script do everything: it creates all three tables from the shipped schemas (including ByOrg), then batch-writes every item, retrying anything DynamoDB leaves unprocessed — safe to re-run. You need the aws CLI and a way to run DynamoDB Local; Docker is easiest. From the extracted partiql-stage/ folder:

bash
# 1. run DynamoDB Local (Docker shown; any method works)docker run -p 8000:8000 amazon/dynamodb-local# 2. from the folder you downloaded: create all three tables and load#    2,595 items (defaults to localhost:8000 — no AWS account needed)node seed-stage-tables.mjs

When it finishes, point DynoStudio at the same endpoint (http://localhost:8000) and open the tables. One table only? node seed-stage-tables.mjs --only stage.Orders.

The indexes: one ships, two are lessons

  • ByOrg (on stage.Users) — ships with the setup above, so FROM "stage.Users"."ByOrg" works from your very first page.
  • byEmail (on stage.Users) — deliberately not pre-created: building it is the CREATE GLOBAL INDEX lesson. The email attribute is already on every profile, so it backfills the moment you run the statement.
  • byRegionStatus (on stage.Orders) — the multi-key GSI from Targeted reads. Its key attributes (region, tenant, status, createdAt) are on every seeded order; create it now if you want that example live when you reach it:
sql
CREATE GLOBAL INDEX "byRegionStatus" ON "stage.Orders"  PARTITION KEY (region, tenant)  SORT KEY (status, createdAt)  PROJECT ALL

Confirm it worked

However you loaded it, open stage.Users and run one cheap keyed read:

sql
SELECT Name, balance, address.cityFROM "stage.Users" WHERE pk = 'User#9'

One row: Ada Okafor · 1,420.50 · Lagos. That's the keyed read from the First queries playground, so if it comes back you're fully set up. (Table-name error or empty result? The import/seed didn't land — re-run the path above.)

Recap
  • Three tables — stage.Users, stage.Outbox, stage.Orders — all keyed pk (string) + sk (string), on-demand.
  • Import path: create the tables (UI or CREATE TABLE), add ByOrg, then Import from CSV & JSON per table.
  • Local path: docker run … amazon/dynamodb-local, then node seed-stage-tables.mjs, then point DynoStudio at http://localhost:8000.
  • ByOrg ships; byEmail and byRegionStatus are created in the studio — that's part of the course.
  • A keyed read on pk = 'User#9' returns Ada Okafor — proof the data landed.
AWS reference
Was this page helpful?