exam questions

Exam AWS Certified Database - Specialty All Questions

View all questions & answers for the AWS Certified Database - Specialty exam

Exam AWS Certified Database - Specialty topic 1 question 37 discussion

Exam question from Amazon's AWS Certified Database - Specialty
Question #: 37
Topic #: 1
[All AWS Certified Database - Specialty Questions]

An online gaming company is planning to launch a new game with Amazon DynamoDB as its data store. The database should be designated to support the following use cases:
✑ Update scores in real time whenever a player is playing the game.
✑ Retrieve a player's score details for a specific game session.
A Database Specialist decides to implement a DynamoDB table. Each player has a unique user_id and each game has a unique game_id.
Which choice of keys is recommended for the DynamoDB table?

  • A. Create a global secondary index with game_id as the partition key
  • B. Create a global secondary index with user_id as the partition key
  • C. Create a composite primary key with game_id as the partition key and user_id as the sort key
  • D. Create a composite primary key with user_id as the partition key and game_id as the sort key
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
BillyMadison
Highly Voted 3 years, 9 months ago
I'm going with D based on the following links. https://aws.amazon.com/blogs/database/amazon-dynamodb-gaming-use-cases-and-design-patterns/ "EA uses the user ID as the partition key and primary key (a 1:1 modeling pattern)." https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/ "Partition key and sort key: Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key."
upvoted 19 times
...
JobinAkaJoe
Highly Voted 3 years, 9 months ago
D is the best choice of keys for below requirements. ✑ Update scores in real time whenever a player is playing the game. -- user_id being partition key ✑ Retrieve a player's score details for a specific game session. -- game_id sort key
upvoted 10 times
...
MultiAZ
Most Recent 1 year, 6 months ago
Selected Answer: D
I go for D - user_ID for global score - user_ID (PK) + game_id (SK) for a session
upvoted 1 times
...
silvaa360
1 year, 7 months ago
Selected Answer: C
- game_id must reflect the game session and not the actual game, because if not even user_id + game_id would not be unique. Saying that, game_id will have higher cardinality. - about the query... if it is to get the details of one specific player, both c and d will work, if we want to get the details of all players for a game, only c works. Having this said, for me C) is the only answer that will work for all cases, having a higher cardinality value as partition key. But let me say that these types of questions must be better elaborated, because at some times it dependends on the interpretation
upvoted 3 times
...
dnelub
2 years, 1 month ago
this is my humble contribution to the solution: If we want to get the high score for a player for a certain game, user_id should be our partition key and game_id should be our sort key, which is D, but to find out what the highest score ever was for a certain game, we would need game_id to be a partition key and 'score' to be the sort key, which is not in the options. I mean that cardinality can be decided according to the objective of the query but it is not given explicitly in the question.
upvoted 1 times
...
jthuma
2 years, 6 months ago
D. Game_id would have lower cardinality than user_id. Say the gaming company only had 4 games with 2m users. You would want your partition to be by higher cardinality and your secondary with lower.
upvoted 2 times
Paulv82003
2 years, 1 month ago
"each game has a unique game_id" what are you talking about "Game_id would have lower cardinality than user_id"? both unique.
upvoted 2 times
...
...
fserrano
2 years, 7 months ago
I'm going with C, for queries and updates game_id and user_id are always used, in addition, game_id has more high cardinality and avoids "hot" partitions if used as the partition key.
upvoted 3 times
...
JeanGat
2 years, 9 months ago
Selected Answer: D
D. There are going to be more user_ids than game_ids, hence user_id will be the higher cardinality value = the better partition key. For those of you saying "C", are you telling me Electronic Arts has more unique games than they have users!!??! https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/
upvoted 5 times
TiredDad
2 years ago
each game has a unique game_id.. meaning if you play same game (e.g. car racing) two times, each time you play the game, it will have a unique game id.. that is what I understand from the question.. because you can't have just one game id for car racing then how will you store data for same user id playing same game multiple times?
upvoted 1 times
...
...
praffuln
3 years, 1 month ago
Selected Answer: C
If there will be player_id it will cause of hot partitioning. So D is wrong. C is correct as game_id will have more high cardinality
upvoted 2 times
...
khchan123
3 years, 1 month ago
C is the answer. ✑ Scores should be updated in real time anytime a player is engaged in the game. -> game_id is the partition key ✑ Retrieve the information of a player's score for a certain gaming session. - > game_id and user_id is the primary key (i.e. user_id is the sort key)
upvoted 3 times
...
novice_expert
3 years, 2 months ago
Selected Answer: D
use cases: ✑ Scores should be updated in real time anytime a player is engaged in the game. (query based on user_id only => user_id partition key) ✑ Retrieve the information of a player's score for a certain gaming session.(query based on user_id + game_id=> user_id partition key, and game_id sort key) D. Create a composite primary key with user_id as the partition key and game_id as the sort key
upvoted 2 times
TiredDad
2 years ago
Scores should be updated in real time anytime a player is engaged in the game. in this case, query will be based on user_id and game_id.. otherwise you will end up fetching all records for that user_id
upvoted 1 times
...
...
randss
3 years, 3 months ago
Answer is C, partition key must have high cardinality ie. game_id as there may be multiple instances of games played by each user.
upvoted 2 times
...
ugo009
3 years, 3 months ago
I chose D. GSI does not support strong consistency.
upvoted 1 times
...
ChauPhan
3 years, 8 months ago
For me, both C and D can be used but C is better. ✑ Update scores in real time whenever a player is playing the game. => Query by the game_id first, then update relevant user_id with his relevant score. ✑ Retrieve a playerג€™s score details for a specific game session => game_id can be used to query then specify the user_id D can do the same as above. But for the query such as: Top score player for each game, C is better. D is for the query such as: This player plays how many games and the score of each.
upvoted 1 times
...
uupadhyay
3 years, 9 months ago
Why not C ? Any idea ?
upvoted 1 times
jove
3 years, 6 months ago
Partition key should have high cardinality. Therefore user id is better than game id as the partition key.. Answer is D
upvoted 5 times
...
...
Dip11
3 years, 9 months ago
I would go with A. Reason, Need user_id as partition key for main table and global secondary index with game_id as partition key since we want to update via user_id and also retrieve via game_id. Both these options do not exists in any of the options so A seems to be nearest correct answer.
upvoted 2 times
nideesh
3 years, 6 months ago
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html GameScores is identified by a partition key (UserId) and a sort key (GameTitle). A query that specified the key attributes (UserId and GameTitle) would be very efficient Composite primary key is the answer. For building a leader board we need global secondar index
upvoted 1 times
...
...
LMax
3 years, 9 months ago
Answer D
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...