Bird
0
0

You need to design a DynamoDB table for a social media app to store user posts with fast read/write and flexible querying. Which design choice best fits this use case?

hard📝 Application Q8 of 15
AWS - DynamoDB
You need to design a DynamoDB table for a social media app to store user posts with fast read/write and flexible querying. Which design choice best fits this use case?
AUse a composite key with UserID and a fixed constant as sort key
BUse a single partition key as PostID only, ignoring user grouping
CUse only a sort key without a partition key
DUse a partition key as UserID and sort key as PostTimestamp to organize posts by user and time
Step-by-Step Solution
Solution:
  1. Step 1: Analyze data access patterns for social media posts

    Users often want to see their posts sorted by time, so partitioning by UserID and sorting by timestamp is ideal.
  2. Step 2: Evaluate other options

    Use a single partition key as PostID only, ignoring user grouping loses user grouping, making queries inefficient. Use a composite key with UserID and a fixed constant as sort key uses a fixed constant, which prevents sorting. Use only a sort key without a partition key is invalid as partition key is required.
  3. Final Answer:

    Use a partition key as UserID and sort key as PostTimestamp to organize posts by user and time -> Option D
  4. Quick Check:

    Table design for user posts = C [OK]
Quick Trick: Partition by user, sort by time for social media posts [OK]
Common Mistakes:
MISTAKES
  • Ignoring partition key importance
  • Using fixed constants as sort keys
  • Trying to use sort key without partition key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes