Skip to content

Traverse a relationship both ways

An index that swaps the partition and sort keys reads the same edges from the other side.

Why

A maintainer belongs to many projects, and a project has many maintainers. Each membership is stored once, as an edge item keyed pk = PERSON, sk = PROJECT, carrying a second pair of keys that swap the two: gsi1pk = PROJECT, gsi1sk = PERSON.

So the base table answers 'Ada's projects' and the inverted index answers 'httpkit's maintainers', from the very same edges. One relationship, two directions, nothing duplicated. The profile items carry no index keys, so only the edges appear in the index.

Store a many-to-many as edges, then an inverted index, partition and sort swapped, reads the relationship from either side.

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. On the base table, Ada's partition holds one edge per project she maintains.

  2. The same edges, read through the inverted index keyed the other way round: who maintains httpkit.

  3. No sort-key condition: Ada's whole collection, her profile and every edge, in one Query.

Built on this

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

On the base table, Ada's partition holds one edge per project she maintains.

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
pk(pk)
sk(sk)
name
lang
gsi1pk
gsi1sk
role
PERSON#ada
PERSON#adaS
AdaS
—
—
—
—
PERSON#ada
PROJ#httpkitS
—
—
PROJ#httpkitS
PERSON#adaS
reviewerS
PERSON#ada
PROJ#zlib2S
—
—
PROJ#zlib2S
PERSON#adaS
leadS
PERSON#mei
PERSON#meiS
MeiS
—
—
—
—
PERSON#mei
PROJ#dataframeS
—
—
PROJ#dataframeS
PERSON#meiS
leadS
PERSON#raj
PERSON#rajS
RajS
—
—
—
—
PERSON#raj
PROJ#dataframeS
—
—
PROJ#dataframeS
PERSON#rajS
reviewerS
PERSON#raj
PROJ#httpkitS
—
—
PROJ#httpkitS
PERSON#rajS
leadS
PROJ#dataframe
PROJ#dataframeS
dataframeS
PythonS
—
—
—
PROJ#httpkit
PROJ#httpkitS
httpkitS
RustS
—
—
—
PROJ#zlib2
PROJ#zlib2S
zlib2S
CS
—
—
—
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