DynamoDB


Keys

Partition key

PK (id) name
person1 Kuba
person2 Mateusz

Person with id 1

PK = person1 -> { PK: person1, name: kuba }


Partition key & Sort key

PK (kind) SK (name) age
person Kuba 27
person Mateusz 34
animal Ollie 3
animal Kiara 7

Animals starting with K

PK = animal, SK begins_with(K) -> [{ PK: animal, SK: Kiara, age: 7}]




Secondary indexes

PK (kind) SK (name) GSI1_PK (city)
person Kuba Zabrze
person Mateusz Katowice
animal Ollie Katowice
animal Kiara Zabrzze

City Katowice

GSI1_PK = Katowice ->

[
    { PK: person, SK: Kuba, GSI1_PK: Mateusz},
    { PK: animal, SK: Kiara, GSI1_PK: Zabrze}
]



Single table design

PK SK GSI1_PK GSI1_SK
AUTHOR#1 AUTHOR#1 AUTHOR Michał
AUTHOR#1 POST#1 POST KMS introduction
AUTHOR#2 AUTHOR#2 AUTHOR Bogusław
AUTHOR#2 POST#2 POST Single table design

All authors

GSI_PK = AUTHOR


All posts by author

PK = AUTHOR#2, SK begins_with(POST)


Author metadata*

PK = AUTHOR#1, SK = AUTHOR#1