Bird
0
0

Consider a DynamoDB table 'Orders' with partition key 'OrderId'. What will the following query return?

medium📝 Predict Output Q4 of 15
AWS - DynamoDB
Consider a DynamoDB table 'Orders' with partition key 'OrderId'. What will the following query return?
const params = {
  TableName: 'Orders',
  KeyConditionExpression: 'OrderId = :oid',
  ExpressionAttributeValues: { ':oid': { S: 'A123' } }
};
const data = await client.query(params);
console.log(data.Items);
AAn error because query requires a sort key condition.
BAn array of items with OrderId equal to 'A123'.
CAn empty array if no items match the condition.
DAll items in the 'Orders' table.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the query parameters

    The query uses a KeyConditionExpression with the partition key 'OrderId' equal to 'A123'.
  2. Step 2: Query behavior

    Query returns all items matching the partition key; sort key is optional if not defined.
  3. Step 3: Output

    It returns an array of matching items or an empty array if none found.
  4. Final Answer:

    An array of items with OrderId equal to 'A123'. -> Option B
  5. Quick Check:

    Query returns items matching partition key [OK]
Quick Trick: Query returns items matching partition key [OK]
Common Mistakes:
  • Assuming query always needs a sort key condition
  • Expecting an error when no sort key is specified
  • Confusing query with scan operation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes