AWS DynamoDB Query Operation

Orders with Costs Greater than 10

Question

A CustomerOrders DynamoDB table has the following items. Customer Name (PK) Order Item Cost Albert Einstein Candle 15 Albert Einstein Spaceship Toy 50 Albert Einstein Hair Comb 5 Isaac Newton Bag of Apples 15 Which operation would you use to find all orders with costs greater than 10?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer: C.

Option A is incorrect because a query operation requires a partition key name and value to be specified (Customer Name in this case)

This would limit results to a specific customer.

Option B is incorrect because a query operation requires a partition key name and value to be specified (Customer Name in this case)

This would limit results to a specific customer.

Option C is CORRECT because a scan operation can be used to read every item in a table.A filter expression parameter can be used to narrow down the results based on some required criteria (Cost of the item in this case).

Option D is incorrect because the projection-expression parameter is used to limit what attributes are returned as part of the result.

Reference:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html

To find all orders with costs greater than 10, you can use the "scan" operation with the "filter-expression" parameter. The "scan" operation allows you to read all the items in a table, while the "filter-expression" parameter enables you to filter the results based on specific conditions.

Option A, which is the "query" operation with the "key-condition-expression" parameter, is not suitable for this scenario since it only returns items with a specific partition key value. In this case, we want to retrieve all items with a cost greater than 10, regardless of the partition key value.

Option B, which is the "query" operation with the "filter-expression" parameter, is also not appropriate because the "filter-expression" parameter in a query operation only applies to non-key attributes. In this case, "Cost" is a key attribute, so the query operation cannot use the "filter-expression" parameter for it.

Option D, which is the "scan" operation with the "projection-expression" parameter, is not relevant to this scenario since the "projection-expression" parameter only specifies which attributes to return, but not how to filter them.

Therefore, the correct answer is option C, which is the "scan" operation with the "filter-expression" parameter. The filter expression will be "Cost > 10" to return all items with a cost greater than 10. However, it is important to note that the "scan" operation can be inefficient and expensive for large tables. It is recommended to use the "query" operation whenever possible to minimize the amount of data read from a table.