1 個回答
- 最新
- 最多得票
- 最多評論
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.
已回答 2 年前
相關內容
- 已提問 1 年前
- AWS 官方已更新 2 年前
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?