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
posta 2 anni fa340 visualizzazioni
1 Risposta
0
Risposta accettata

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
con risposta 2 anni fa
profile picture
ESPERTO
verificato 24 giorni fa
  • thank you!

  • Sure thing, feel free to accept the answer.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande