Q35 — AWS DVA-C02 Ch.1
Question 35 of 100 | ← Chapter 1
An application adds a processing date to each transaction it receives. The application uses the PutItem operation to write each transaction into an Amazon DynamoDB table. Each transaction has a unique ID (transactionID). Occasionally, the application receives duplicate transactions. A developer notices that duplicate transactions in DynamoDB have the latest processing date instead of the date when the transaction was first received. Duplicate records occur infrequently, and the majority of transactions are unique. What is the most cost-effective solution the developer can implement to ensure PutItem does not overwrite existing records?
- A. First call the GetItem operation to confirm the record does not exist, then call PutItem.
- B. Enable TTL (Time-to-Live) attribute on the DynamoDB table.
- C. Implement a conditional put using the attribute_exists(transactionID) condition expression.
- D. Implement a conditional put using the attribute_not_exists(transactionID) condition expression. ✓
Correct Answer: D. Implement a conditional put using the attribute_not_exists(transactionID) condition expression.
Explanation
DynamoDB condition expressions allow checking conditions during write operations such as PutItem. To ensure PutItem does not overwrite existing records, the operation must succeed only if the transactionID does not already exist. Option D achieves this using the attribute_not_exists(transactionID) condition expression—PutItem succeeds only when transactionID is absent, preventing overwrites. Option A is viable but inefficient due to the extra GetItem call. Option B’s TTL is irrelevant here, as it governs automatic item expiration—not write prevention. Option C’s attribute_exists checks for existence, which contradicts the requirement. Thus, D is the most cost-effective solution. 【Lantern Certification provided by: swufelp1999】