Q9 — AWS DVA-C02 Ch.1
Question 9 of 100 | ← Chapter 1
A company caches web application session data in an Amazon DynamoDB table. The company wants an automated method to delete old items from the table. What is the simplest solution?
- A. Write a script to delete old records; schedule the script as a cron job on an Amazon EC2 instance.
- B. Add an expiration timestamp attribute; enable Time-to-Live (TTL) based on that attribute. ✓
- C. Create a new table daily to store session data; delete the previous day's table.
- D. Add an attribute with an expiration timestamp; name the attribute ItemExpiration.
Correct Answer: B. Add an expiration timestamp attribute; enable Time-to-Live (TTL) based on that attribute.
Explanation
Option B is the simplest solution. In Amazon DynamoDB, adding an expiration timestamp attribute and enabling Time-to-Live (TTL) based on that attribute automatically deletes old items without requiring manual scripting or complex table operations. Option A introduces unnecessary complexity and maintenance overhead. Option C is overly cumbersome and inefficient. Option D adds an attribute but does not enable TTL functionality, so it cannot achieve automatic deletion. Therefore, Option B is optimal.