Course menuDEA-C01

Exams / DEA-C01 / DynamoDB data modeling / Question 1

DEA-C01 practice question: DynamoDB data modeling (1 of 2)

Data Store Management A free question from our original DEA-C01 practice exam. Try it, then open the answer to see why each option is right or wrong.

Last verified against current AWS documentation ·How we write our questions

A public library consortium stores loan records in one Amazon DynamoDB table. Two access patterns matter most: the members' app lists a member's current loans, and the catalog team looks up which members hold a given book. The first design used branch_id as the partition key, so one busy central branch receives most of the writes.

The team wants both access patterns served by queries rather than scans, and it wants the writes spread evenly across partitions.

Which table design meets these requirements?

Choose one answer.

  1. A. Keep branch_id as the partition key, and add a global secondary index on member_id so that the member's loans can be queried.
  2. B. Use book_id as the partition key with no sort key, and rely on scans for the member's loans, which the app runs once a day.
  3. C. Use a random number from 1 to 10 appended to branch_id as the partition key, and scan all ten suffixes for each member lookup.
  4. D. Use member_id as the partition key and loan_date as the sort key, and add a GSI with book_id as its partition key.
Show the answer and explanation

Answer: D

  • A. Wrong: The base table still concentrates writes on the busy branch, so the hot partition remains. The global secondary index helps the member lookup but does not spread the writes the team asked to balance.
  • B. Wrong: Scans read the whole table and are expensive at scale, and the team wants queries. A partition key on book_id can also concentrate popular titles on a few partitions.
  • C. Wrong: Write sharding spreads the writes, but reading a member's loans then needs ten queries for each lookup. The option also scans for the catalog pattern, which the team wanted served by queries.
  • D. Right: Correct. Member IDs have many distinct values, so writes spread across partitions, and a member's loans are one query. The index on book_id answers the catalog team's lookup with a query instead of a scan. Learn more: Best practices for designing and architecting with DynamoDB (opens in a new tab)

Explanation

DynamoDB spreads items by partition key, so a key with many distinct values, such as member ID, avoids a single busy partition. A sort key on loan date keeps a member's loans in one query, and a global secondary index on book ID serves the catalog lookup by query. Keeping branch as the key or scanning either access pattern leaves one of the requirements unmet.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

Want more on DynamoDB data modeling? The 5 full-length practice sets have 10 more DynamoDB data modeling questions, 325 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets