Which choice of keys is recommended for the DynamoDB table?
Create a global secondary index with game_id as the partition key
Create a global secondary index with user_id as the partition key
Create a composite primary key with game_id as the partition key and user_id as the sort key
Create a composite primary key with user_id as the partition key and game_id as the sort key
Explanations:
A global secondary index withgame_idas the partition key would not support efficient querying byuser_idfor score details, which is required.
A global secondary index withuser_idas the partition key would not support efficient querying bygame_idfor the game session.
Using a composite primary key withgame_idas the partition key anduser_idas the sort key would make it inefficient to retrieve a player’s score for a specific session.
A composite primary key withuser_idas the partition key andgame_idas the sort key allows for fast retrieval of a player’s score details byuser_idandgame_id. This structure efficiently supports both use cases.