1 Answer
- Newest
- Most votes
- Most comments
0
I suggest you have a PK of <user> and an SK of FAVORITEKITCHEN#<kitchen> and then you can fetch all the favorites for that user with one query using a begins-with on the SK. Note this will fetch the kitchen id and can fetch any other kitchen metadata that you choose to denormalize into the favorite kitchen item. If you're thinking "But I don't want to duplicate kitchen metadata into every user favoriting that kitchen" then your alternative is to fetch the metadata with a second batch-get-items. Denormalizing works better at scale.
answered 2 years ago
Relevant content
- asked 5 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Thank you for your answer. Your first solution I didn't use it because of the duplication as you stated. Your second solution might be a better approach. However, it contradicts the main reason of using a single table design, which is retrieving all the required data in a single request. But is there any other solution? And which one do you think is the best practice, first or second solution?