DVA-C02 exam dumps

DVA-C02 practice question 93 of 399

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

DVA-C02 Question 93

Single answer

You are developing an application that uses Amazon DynamoDB to store customer data. The table's primary key consists of a 'CustomerID' partition key and a 'OrderDate' sort key. You need to retrieve all orders placed by a specific customer within the past 30 days. Which operation is the most efficient for this use case?

  1. A

    Use the Query operation with a key condition expression to filter by 'CustomerID' and 'OrderDate'.

  2. B

    Use the Scan operation with a filter expression to filter by 'CustomerID' and 'OrderDate'.

  3. C

    Use the Scan operation without any filters and manually process the results in your application code.

  4. D

    Use the Query operation without any key condition expression and apply filters in the application layer.

Show answer and explanation

Correct answer: A

Explanation

The Query operation is designed to retrieve items based on their primary key values, making it the most efficient method for retrieving all orders for a specific 'CustomerID'. The use of a key condition expression ensures that only relevant items are returned, avoiding the overhead of scanning the entire table as required by the Scan operation.

  • A. Correct.

    Correct: The Query operation is more efficient because it retrieves items directly based on the primary key values. Using a key condition expression allows you to filter results by 'CustomerID' and 'OrderDate' efficiently.

  • B. Incorrect.

    Incorrect: The Scan operation examines every item in the table, which is inefficient compared to a Query for this use case. Even with a filter expression, the entire table must still be scanned.

  • C. Incorrect.

    Incorrect: This is the least efficient approach as it requires scanning the entire table and manually filtering results in your application, which increases latency and resource usage.

  • D. Incorrect.

    Incorrect: A Query operation without a key condition expression is invalid in this scenario because a Query requires at least the partition key ('CustomerID') to be specified. Additionally, applying filters in the application layer is inefficient.

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