Single-table design · Lesson 18 of 20
One index, many questions
Different entity types share generic index keys, so one index serves several access patterns.
Why
Here one table holds projects and tasks, and one index, GSI1, serves both. The trick is generic key names: projects write OWNER#ada into gsi1pk, tasks write STATUS#doing into the same attribute.
So one index answers 'Ada's projects' and 'tasks in progress': two access patterns, two entity types, one set of index keys. This overloading is the heart of single-table design.
Generic, overloaded keys let one index do the work of many. That is how a single table serves a whole application.
Workspacedynoxide · wasm · DynamoDB API 2012-08-10 · contract 1
Try an example
On GSI1, project items set gsi1pk to OWNER#ada. So this Query returns Ada's projects.
pk(pk)
sk(sk)
name
gsi1pk
gsi1sk
title
Run an operation to see the raw engine response.
table Workspacekeys pk / skitems 19