# Bean & Bark: set up the table

Before the first lesson you need two things: a table called `BeanAndBark`, and the sample data inside it. Both take a couple of minutes. Pick the path that matches how you want to run — **import the ready-made file straight into DynoStudio** (no AWS account, nothing to install beyond the app), or **stand up a free local DynamoDB** and load it with one command. Either way you end up in the same place: the studio pointed at a loaded table, ready to query.

**You'll learn**

- Create the `BeanAndBark` table — the one-table, `pk`/`sk` shape the whole series is built on
- Load the ~5,900-item sample, either by **importing** it into DynoStudio or **seeding** DynamoDB Local
- Point DynoStudio at your data and confirm it with a single cheap query

> **What you're building:** One DynamoDB table, `BeanAndBark`, keyed by `pk` (string) + `sk` (string), on-demand billing. Every entity — customers, orders, subscriptions, products — lives in that one table, told apart by a key prefix. That single-table shape is the whole point of the tutorial; [DynamoDB basics](https://www.kanject.com/docs/dynostudio-dynamodb-basics/) explains *why* it's one table and not four.

## Get the files

**One download covers both paths:** the bundle below holds the dataset, the table definition, the local seed script, and the dataset README. Prefer single files? Each one is listed after it. The `.ddb.json` file is what you import into DynoStudio; `schema.json` and the seed script are for the run-it-locally path.

**Download**

- [Everything — bean-and-bark.zip](/datasets/bean-and-bark/bean-and-bark.zip) — The whole dataset in one file. Extract it and you're ready for either path below.
- [Bean & Bark sample (DynamoDB-JSON)](/datasets/bean-and-bark/bean-and-bark.ddb.json) — The dataset — ~5,900 items in DynamoDB-typed form. This is the file you import into DynoStudio.
- [Table definition](/datasets/bean-and-bark/schema.json) — The BeanAndBark key schema (pk HASH / sk RANGE, on-demand) — used by aws dynamodb create-table and by the seed script.
- [Local seed script](/datasets/bean-and-bark/seed-bean-and-bark.mjs) — A zero-dependency loader for DynamoDB Local — only needed for the run-it-locally path below. Uses the aws CLI you already have.

## Path A — Import into DynoStudio

The fastest way in: nothing to install beyond the app, no AWS account. You create an empty table, then import the file into it. Two steps.

**1. Create the table.** In DynoStudio, create a new table named `BeanAndBark` with partition key `pk` (String) and sort key `sk` (String), billed on-demand. Prefer to type it? Run this statement in the query box — DynoStudio lowers it to the native `CreateTable` call and shows you the plan in the "Executes as" strip before anything runs:

```sql
CREATE TABLE "BeanAndBark" (
  PARTITION KEY pk STRING,
  SORT KEY sk STRING
) WITH BILLING = ON_DEMAND
```

That's the exact key shape the lessons assume. `CREATE TABLE` is a DynoStudio dialect surface — DynamoDB's own PartiQL has no DDL; see [CREATE TABLE](https://www.kanject.com/docs/dynostudio-create-table/) for the full syntax. A read-only stage refuses it, which is why the studio discloses the control-plane call first.

**2. Import the data.** Open the table, choose **Import from CSV & JSON**, pick the `bean-and-bark.ddb.json` you downloaded, and review the **key-aware preview** before it writes. That loads the ~5,900 items — and you're ready to query.

> **Tip:** Done on this path? Skip to [Confirm it worked](https://www.kanject.com/docs/dynostudio-bean-bark-setup/#confirm-it-worked) below — one query proves the data's in, and then the [first lesson](https://www.kanject.com/docs/dynostudio-bean-bark-first-query/) is right there.

## Path B — Run it locally with DynamoDB Local

Prefer to run the PartiQL against your own endpoint, offline and free? Stand up **DynamoDB Local** and let the seed script create the table and load every item for you. You need the `aws` CLI and a way to run DynamoDB Local — Docker is easiest. From the folder you downloaded:

```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 the table and load ~5,900 items
#    (defaults to localhost:8000 — no AWS account, dummy creds injected for you)
node seed-bean-and-bark.mjs
```

The script creates `BeanAndBark` from `schema.json` if it's missing, then batch-writes every item in chunks of 25, retrying anything DynamoDB leaves unprocessed — so it's safe to re-run. When it finishes, **point DynoStudio at the same endpoint** (`http://localhost:8000`) and open the table.

> **Just the table, by hand?:** The seed script creates the table for you. If you'd rather create it yourself from the schema file first, the AWS CLI does it in one line — `aws dynamodb create-table --cli-input-json file://schema.json` — then run the seed script to load the items into it.

> **Seeding real AWS instead of local:** One flag drops the local override and uses your normal credentials and region: `node seed-bean-and-bark.mjs --endpoint '' --region eu-west-1`. That writes ~5,900 items to a **real, billed** table in your account — DynamoDB Local is the free, offline default for a reason. Only reach for this if you specifically want the data in AWS.

## Confirm it worked

However you loaded it, open `BeanAndBark` in DynoStudio and run one cheap keyed read. If Dana's three orders come back, the data is in and the keys are right:

```sql
SELECT OrderId, Placed, Status, Total FROM "BeanAndBark"
WHERE pk = 'CUSTOMER#c-014' AND begins_with(sk, 'ORDER#')
```

You should get **three rows** — `Order#8842`, `Order#9013`, `Order#9188`. That's the opening move of the very first lesson, so if it works you're fully set up. (If it errors on the table name or returns nothing, the import/seed didn't land — re-run the path above.)

> **Your item counts will be smaller — that's expected:** The lessons describe a production table of ~240,000 orders; this sample is a faithful **~5,900-item slice** of it that imports in seconds. Every *answer* the lessons print is reproducible — Dana's three orders, the exact West revenue, the 4,012/214 dormant split — but the raw item counts in the studio's cost strip will be smaller than the numbers in the prose. The lesson is always the *ratio* a Query saves over a Scan, not the absolute count.

**Recap**

- The table is `BeanAndBark`, keyed by `pk` (string) + `sk` (string), billed on-demand — **one** table for every entity.
- **Import path:** create the table (the DynoStudio UI, or a `CREATE TABLE` statement in the query box), then **Import from CSV & JSON** with `bean-and-bark.ddb.json`.
- **Local path:** `docker run … amazon/dynamodb-local`, then `node seed-bean-and-bark.mjs`, then point DynoStudio at `http://localhost:8000`.
- A keyed read on `pk = 'CUSTOMER#c-014'` returns Dana's three orders — proof the data landed.

> **Table's up and loaded — start the tutorial:** You have a `BeanAndBark` table full of real stories. [Answer the founder](https://www.kanject.com/docs/dynostudio-bean-bark-first-query/) is your first real query — find one customer's orders in a single cheap read, and learn to tell a Query from a Scan by watching what each one costs.

**AWS reference**

- [Run DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) — AWS docs: run DynamoDB on your own machine — free, offline, nothing to provision.
- [Working with tables in DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html) — AWS docs: creating tables, key schema, and on-demand vs provisioned billing.

---
_Source: https://www.kanject.com/docs/dynostudio-bean-bark-setup/ · Kanject Docs_
