Matt
Matt

Reputation: 88047

DynamoDB multi-field index

I have some data that is uniquely identified by three values. Imagine a ticket object identified by section, row, and seat number. What is the best way to index a table like that in DynamoDB?

I could create a single field for the index by concatenating section/row/seat into one string. Is that a good practice? Or I could have an arbitrary ID field as the primary index, but I would still need to search for items by section/row/seat using some kind of secondary index.

What is the best practice for DynamoDB indexing in cases like this?

Upvotes: 0

Views: 220

Answers (1)

Sid Ali
Sid Ali

Reputation: 1857

Concat two keys is a good solution, i advice you concat section/row and add as Storting key the seat number, or you can find better combination according to your need.

Knowing that according to the doc

Key Condition Expression

To specify the search criteria, you use a key condition expression—a string that determines the items to be read from the table or index.

You must specify the partition key name and value as an equality condition.

You can optionally provide a second condition for the sort key (if present). The sort key condition must use one of the following comparison operators: < > ..

Upvotes: 2

Related Questions