Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is building a medical monitoring application that stores periodic heart rate readings from wearable sensors in an Amazon DynamoDB table. The table uses `DeviceID` as the partition key and `Timestamp` as the sort key. The developer needs to retrieve all heart rate readings for a specific device that are greater than 100 bpm100\text{ bpm} within a specific 2424-hour window. Which two actions should the developer take to achieve this requirement?

  1. Perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression.Cevap
  2. B
    Perform a `Scan` operation on the table, using a filter expression on `DeviceID` and `Timestamp`.
  3. Use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than 100 bpm100\text{ bpm}.Cevap
  4. D
    Hardcode an IAM user's access keys directly in the AWS SDK client initialization code to bypass any read authorization latency.
  5. E
    Perform a `Scan` operation on a newly created Global Secondary Index (GSI) that has the heart rate as the partition key.

Cevap

To retrieve the heart rate data efficiently, the developer should perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression, and use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than 100 bpm100\text{ bpm}.
To retrieve data efficiently from DynamoDB, the developer should use the `Query` operation. By specifying the partition key (`DeviceID`) and the sort key (`Timestamp`) in the key condition expression, the query only reads the items that belong to that specific device and time window. Because heart rate is a non-key attribute, a filter expression is used to discard items that do not meet the criteria (greater than 100 bpm100\text{ bpm}) before the response is returned to the client, which reduces network utilization.

Adım Adım Çözüm

1
Identify the primary keys of the table.
The table has `DeviceID` as the partition key and `Timestamp` as the sort key.
This allows targeting a specific device and time range directly.
2
Select the appropriate API operation.
A `Query` operation is selected instead of a `Scan` operation.
A `Query` operation reads only the required partition and sort key range, while a `Scan` operation reads all items in the table, wasting Read Capacity Units (RCUs).
3
Determine how to filter non-key attributes.
Use a `FilterExpression` in the query to restrict the response to items where the heart rate is greater than 100 bpm100\text{ bpm}.
Since heart rate is not a key attribute, it cannot be in the key condition expression, but a filter expression will discard non-matching items on the server side to reduce network data transfer.

Anahtar Kavram

Optimizing DynamoDB retrieval using Query operations and FilterExpressions instead of full table Scans, and following secure credential management.
Bu soruyu puanla