About DynamoDB Primary key

0

hi guys!

I am researching Amazon DynamoDB.

About the Primary key, I know that there are 2 options to setup Primary key (Partition key only and Partition key + Sort key). The Partition key + Sort key must be unique.

In the picture below, I don't know what should we do if we have to add the 3rd record that show the same user_id play the same game_id but they have the "draw" Result.

If you know, please tell me! Enter image description here

  • Hi Steven, what does the game_id stand for?

    1. A game type, like "Kart Racing", "Whack-a-Mole"?
    2. Or different rounds of the same game?

    Because, in case of 1) you'd might need more keys if you want more than one result per user+game.

Steven
質問済み 2年前340ビュー
1回答
0
承認された回答

You should probably add more to the sort key like a gameplay_id for the particular play of the game. So your SK becomes "1234#de45a" which is a game_id#gameplay_id concatenated together where de45a is the particular run of the game. Then every game play is tracked, and you can easily query to find all plays by a user, all plays of a user for a particular game, and any particular game play.

You might have different query needs. The data model you pick is directly based on the update and query pattern. I'm just guessing at your query pattern.

AWS
回答済み 2年前
profile picture
エキスパート
レビュー済み 24日前
  • thank you!

  • Sure thing, feel free to accept the answer.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ