Soru

Zorluk: KolayData Store Operations with Amazon DynamoDB

A developer is implementing a microservice for a digital library system. The system needs to retrieve a specific book's metadata using its ISBN (which is the primary key) and retrieve a list of all reviews for a specific book, sorted by the review date.

Which two DynamoDB operations should the developer use to retrieve this data most efficiently with the lowest Read Capacity Unit (RCU) consumption?

  1. Use the GetItem operation to retrieve the book's metadata by its ISBN.Cevap
  2. Use the Query operation to retrieve the reviews for a specific book using its partition key.Cevap
  3. C
    Use the Scan operation with a filter expression on the ISBN to retrieve the book's metadata.
  4. D
    Use the Scan operation to retrieve all reviews in the table and filter them on the client side.
  5. E
    Hardcode the AWS credentials in the SDK client configuration to speed up authentication for DynamoDB calls.

Cevap

The developer should use the GetItem operation to retrieve the book's metadata and the Query operation to retrieve the reviews.
To retrieve a single item by its primary key (ISBN), the GetItem operation is the most direct and efficient option. To retrieve multiple related items (reviews for a book) that share a partition key, the Query operation reads only the matching items, optimizing performance and RCU usage.

Adım Adım Çözüm

1
Analyze the requirements for retrieving the book's metadata.
The book metadata is identified by a unique ISBN (primary key). The most efficient operation to read a single item by its primary key is GetItem.
GetItem directly targets the specific partition key value and avoids reading any other items in the table.
2
Analyze the requirements for retrieving the reviews.
Reviews are associated with a specific book. Using the book's partition key, the Query operation can retrieve all matching review items efficiently.
Query reads only the items that match the specified partition key and can sort them by the sort key, minimizing the amount of data read.
3
Evaluate and eliminate inefficient operations.
Scan operations must be avoided as they examine every item in the table. Hardcoding credentials must be avoided for security compliance.
Scan operations waste Read Capacity Units (RCUs) and increase latency, while hardcoded credentials violate IAM security principles.

Anahtar Kavram

Retrieving items from Amazon DynamoDB efficiently using GetItem and Query operations instead of Scan operations.
Bu soruyu puanla