Skip to content

Model a one-to-many with one partition

A parent and its children share a partition key, so one Query fetches them together.

Why

A playlist has many tracks. Instead of a join, both live in one item collection: the playlist's META record and its TRACK items all share the partition key PLAYLIST#chill.

So 'the playlist and everything in it' is a single Query. The relationship was resolved at write time, by where you put the items, not at read time by joining them.

Co-locate a parent and its children under one partition key, and the join disappears into a single Query.

Try it. Then change it.

Predict what each request will do. Run it, inspect the response, then change a value in the workbench and try again.

  1. One Query on PLAYLIST#chill returns the playlist record and every track under it.

Built on this

PlaylistsDynamoDB workbench
Ready to run
Explore an access patternSelect to load & run

One Query on PLAYLIST#chill returns the playlist record and every track under it.

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
pk(pk)
sk(sk)
name
owner
title
seconds
PLAYLIST#chill
METAS
ChillS
adaS
—
—
PLAYLIST#chill
TRACK#001S
—
—
WeightlessS
485N
PLAYLIST#chill
TRACK#002S
—
—
An EndingS
252N
PLAYLIST#chill
TRACK#003S
—
—
Avril 14thS
120N
PLAYLIST#focus
METAS
FocusS
linusS
—
—
PLAYLIST#focus
TRACK#001S
—
—
SubstrataS
360N
PLAYLIST#focus
TRACK#002S
—
—
Music for 18 MusiciansS
3360N
PLAYLIST#focus
TRACK#003S
—
—
Spiegel im SpiegelS
540N
PLAYLIST#focus
TRACK#004S
—
—
MetamorphosisS
600N
PLAYLIST#focus
TRACK#005S
—
—
GlassworksS
380N
PLAYLIST#energy
METAS
EnergyS
graceS
—
—
PLAYLIST#energy
TRACK#001S
—
—
Lose YourselfS
326N
PLAYLIST#energy
TRACK#002S
—
—
BangarangS
215N
PLAYLIST#energy
TRACK#003S
—
—
TitaniumS
245N
PLAYLIST#energy
TRACK#004S
—
—
LevelsS
340N
PLAYLIST#energy
TRACK#005S
—
—
One More TimeS
320N
PLAYLIST#sleep
METAS
SleepS
adaS
—
—
PLAYLIST#sleep
TRACK#001S
—
—
SleepS
480N
PLAYLIST#sleep
TRACK#002S
—
—
We Move LightlyS
300N
PLAYLIST#sleep
TRACK#003S
—
—
SamanS
510N
PLAYLIST#sleep
TRACK#004S
—
—
Nuvole BiancheS
360N
PLAYLIST#commute
METAS
CommuteS
samS
—
—
PLAYLIST#commute
TRACK#001S
—
—
RoygbivS
180N
PLAYLIST#commute
TRACK#002S
—
—
TeardropS
330N
PLAYLIST#commute
TRACK#003S
—
—
Midnight CityS
244N
PLAYLIST#commute
TRACK#004S
—
—
Open Eye SignalS
460N
Awaiting request
Your next query starts here.

Choose an access pattern above, or build your own request. See what comes back and what it costs.

Powered by DynoxideWASMStarts on your first run · Runs locally in your browser