Example of DynamoDB Implementation using Single Table Design

The idea of Single Table Design was shared in AWS re:Invent 2019 . It is a great idea of solving the problem that typically handled by SQL join tables; at the same time optimise the implementation of DynamoDB from cost & performance perspective. Logical Partition through Partition Key & Sort Key In a nutshell, Single Table Design for DynamoDB uses Partition Key & Sort Key as a logical partition. If you create a DynamoDB table to store booking records for your customer the Partition Key (PK) & Sort Key (SK) can looks like this: PK: CUSTOMER#00001 SK: BOOKING#12345 PK: CUSTOMER#00001 SK: CUSTOMERPROFILE#123 BOOKSLOT#45678 SK: BOOKING#12345 BOOKSLOT#45679 SK: BOOKING#12345 Use PK and SK to link entity together Within the same DynamoDB Table, you can technically store Booking Record (BOOKING#), Booking Slot/ Details Record (BOOKSLOT#) and Customer Record (CUSTOMER#) who created the booking. All thanks to the concept of NoSQL, data with different attributes can a...