A developer is designing a classroom reservation system. The reservation records are stored in an Amazon DynamoDB table. The application needs to support queries to retrieve reservations for a specific classroom by date. To optimize performance and control cost, the developer must select the appropriate key schema and query strategy.
Which design option represents the most efficient and standard-compliant configuration for this requirement?
- ADesign the table with ClassroomID as the partition key, invoke the Scan action using a filter expression to locate specific dates, and authenticate via the default credential provider chain.
- Design the table with ClassroomID as the partition key and ReservationDate as the sort key, and invoke the Query action with a key condition expression while authenticating via the default credential provider chain.Answer
- CDesign the table with ClassroomID as the partition key and ReservationDate as the sort key, invoke the Query action, and initialize the SDK client with hardcoded AWS access keys inside the application code.
- DDesign the table with a single static partition key for all records, and resolve the resulting ProvisionedThroughputExceededException errors by scaling up the table's provisioned Read Capacity Units (RCUs).
Answer
Design the table with ClassroomID as the partition key and ReservationDate as the sort key, and invoke the Query action with a key condition expression while authenticating via the default credential provider chain.
Designing the table with ClassroomID as the partition key and ReservationDate as the sort key allows the application to perform highly efficient Query operations. Querying with a key condition expression avoids scanning the entire table, minimizing consumed Read Capacity Units (RCUs) and latency. Authenticating via the default credential provider chain is the AWS-recommended security best practice as it avoids hardcoding credentials.
Step-by-Step Solution
Key Concept
Selecting the correct DynamoDB key schema and read API operation (Query vs Scan) while maintaining secure AWS SDK authentication.