Which of the following best explains why single-table design is important in DynamoDB?
Think about how DynamoDB handles queries and indexes.
Single-table design reduces the number of tables and uses composite keys and indexes to efficiently query related data without joins.
Given a DynamoDB table with partition key 'PK' and sort key 'SK', storing users and their orders in the same table, what will this query return?
Query: PK = 'USER#123' AND begins_with(SK, 'ORDER#')
Table data example: PK | SK | Attribute USER#123 | ORDER#001 | {amount: 50} USER#123 | ORDER#002 | {amount: 75} USER#123 | PROFILE | {name: 'Alice'} USER#456 | ORDER#001 | {amount: 20}
Look at how the sort key condition filters items.
The query filters items with PK 'USER#123' and SK starting with 'ORDER#', so only orders for that user are returned.
Which of the following DynamoDB query snippets correctly queries all orders for user with ID '123' using single-table design?
Assume table has PK as 'PK' and SK as 'SK'.
Check the correct use of KeyConditionExpression and begins_with function.
Option D uses the correct syntax with KeyConditionExpression and begins_with for the sort key.
You want to efficiently retrieve all comments for a blog post and the post's metadata from a single DynamoDB table. Which design approach best supports this?
Think about how single-table design groups related items.
Using the same partition key groups related items, and sort key prefixes let you query specific item types efficiently.
A developer runs this DynamoDB query to get all orders for user '123', but it returns no results:
query({
KeyConditionExpression: 'PK = :pk AND SK = :sk',
ExpressionAttributeValues: { ':pk': 'USER#123', ':sk': 'ORDER#' }
})What is the most likely reason?
Consider how sort keys are structured in single-table design.
The query uses '=' on SK, but SK values have order IDs appended, so no exact match with 'ORDER#' exists. Using begins_with is needed.