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
demandé il y a 2 ans340 vues
1 réponse
0
Réponse acceptée

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
répondu il y a 2 ans
profile picture
EXPERT
vérifié il y a 24 jours
  • thank you!

  • Sure thing, feel free to accept the answer.

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions