DVA-C02 exam dumps

DVA-C02 practice question 84 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 84

Single answer

You are designing a DynamoDB table to store user activity logs for a mobile application. Each log entry includes a user ID, timestamp, and activity type. The application's users are globally distributed, and activity logs are frequently queried by user ID and timestamp range. To ensure balanced partition access and avoid hot partitions, how should you design the partition key?

  1. A

    Use 'user ID' as the partition key and 'timestamp' as the sort key.

  2. B

    Use a composite key combining 'user ID' and a hashed value of 'timestamp' as the partition key.

  3. C

    Use 'region' as the partition key and 'user ID' as the sort key.

  4. D

    Use a random UUID as the partition key and store all other attributes as additional columns.

Show answer and explanation

Correct answer: B

Explanation

To ensure balanced partition access in DynamoDB, the partition key must have high cardinality and distribute data evenly across partitions. By using a composite key combining 'user ID' and a hashed value of 'timestamp,' you can achieve even data distribution while retaining the ability to query efficiently by user ID and timestamp range.

  • A. Incorrect.

    Using only 'user ID' as the partition key could result in hot partitions if certain users generate a high volume of activity logs, as queries would frequently target a small subset of partitions.

  • B. Correct.

    A composite key combining 'user ID' and a hashed value of 'timestamp' ensures high cardinality by spreading the data across multiple partitions while still allowing efficient queries by user ID and timestamp range.

  • C. Incorrect.

    Using 'region' as the partition key would not adequately distribute data because many users within the same region could cause uneven partition usage, leading to hot partitions.

  • D. Incorrect.

    Using a random UUID as the partition key would create high cardinality, but it would make querying by user ID and timestamp range inefficient, as no meaningful relationship exists between the keys and query patterns.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam