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
feita há 2 anos340 visualizações
1 Resposta
0
Resposta aceita

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
respondido há 2 anos
profile picture
ESPECIALISTA
avaliado há 24 dias
  • thank you!

  • Sure thing, feel free to accept the answer.

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas