
Answer-first summary for fast verification
Answer: Conditional writes
Correct option: Conditional writes - DynamoDB optionally supports conditional writes for write operations (PutItem, UpdateItem, DeleteItem). A conditional write succeeds only if the item attributes meet one or more expected conditions. Otherwise, it returns an error. For example, you might want a PutItem operation to succeed only if there is not already an item with the same primary key. Or you could prevent an UpdateItem operation from modifying an item if one of its attributes has a certain value. Conditional writes are helpful in cases where multiple users attempt to modify the same item. This is the right choice for the current scenario. Incorrect options: Batch writes - Bath operations (read and write) help reduce the number of network round trips from your application to DynamoDB. In addition, DynamoDB performs the individual read or write operations in parallel. Applications benefit from this parallelism without having to manage concurrency or threading. But, this is of no use in the current scenario of overwriting changes. Atomic Counters - Atomic Counters is a numeric attribute that is incremented, unconditionally, without interfering with other write requests. You might use an atomic counter to track the number of visitors to a website. This functionality is not useful for the current scenario. Use Scan operation - A Scan operation in Amazon DynamoDB reads every item in a table or a secondary index. By default, a Scan operation returns all of the data attributes for every item in the table or index. This is given as a distractor and not related to DynamoDB item updates.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A startup company has been testing DynamoDB in their latest development environment. During their trials, the development team found that certain write operations are inadvertently overwriting existing items that share the same primary key. This issue has caused significant data inconsistencies.
What DynamoDB write option should the team choose in order to avoid overwriting existing items with the same primary key?
A
Conditional writes
B
Batch writes
C
Atomic Counters
D
Use Scan operation
No comments yet.