You have a DynamoDB table named Users with UserID as the primary key. Which query will return the item with UserID equal to 123?
Use the simplest method to get an item by its primary key without scanning the whole table.
GetItem is the most efficient way to retrieve a single item by its primary key. Query requires a partition key and is used for composite keys, but GetItem is simpler here. Scan reads the whole table and is inefficient. UpdateItem modifies data, not retrieves.
Which statement best describes the role of a partition key in a DynamoDB table?
Think about how DynamoDB organizes data physically.
The partition key uniquely identifies each item and decides which partition stores the item. It is mandatory and essential for fast lookups. Sorting happens with a sort key, not the partition key.
You want to add a new attribute Age with value 30 to an existing item with UserID = 101 in DynamoDB. Which UpdateItem syntax is correct?
Remember the syntax for UpdateExpression requires an equals sign and placeholders for values.
The correct syntax uses SET Age = :val with a placeholder :val defined in ExpressionAttributeValues. Option C uses ADD which is for numeric increments, not setting values. Option C misses the equals sign. Option C uses a literal value without a placeholder, which is invalid.
You have a DynamoDB table with UserID as the partition key and OrderDate as a sort key. You want to efficiently query all orders placed on a specific OrderDate regardless of UserID. What is the best approach?
Think about how to query by an attribute that is not the primary key.
A Global Secondary Index allows you to query the table using a different partition key, here OrderDate. Local Secondary Indexes share the same partition key as the base table, so they can't be used to query by OrderDate alone. Scan reads the whole table and is inefficient. Querying by UserID won't help if you want all orders on a date regardless of user.
You try to update an item in DynamoDB with a ConditionExpression to only update if Status is "Pending". The update fails with a ConditionalCheckFailedException. What is the most likely cause?
Think about what happens if the item you want to update is missing.
If the item does not exist, the condition Status = "Pending" cannot be true, so the conditional update fails with ConditionalCheckFailedException. Misspelling the attribute would cause a different error. The syntax error would cause a syntax exception. Update supports conditional expressions.