Bird
0
0

Which of the following is the correct syntax to define a partition key named 'OrderId' in a DynamoDB table using AWS CLI?

easy📝 Syntax Q3 of 15
DynamoDB - Access Patterns and Query Optimization
Which of the following is the correct syntax to define a partition key named 'OrderId' in a DynamoDB table using AWS CLI?
Aaws dynamodb create-table --table-name Orders --key-schema AttributeName=OrderId,KeyType=RANGE --attribute-definitions AttributeName=OrderId,AttributeType=N --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Baws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Caws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=BS --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Daws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=Z --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Step-by-Step Solution
Solution:
  1. Step 1: Check correct key type and attribute type

    Partition key uses KeyType=HASH and attribute type S (string) or N (number).
  2. Step 2: Validate syntax correctness

    aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 uses KeyType=HASH and AttributeType=S correctly; others have wrong KeyType or invalid AttributeType.
  3. Final Answer:

    aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=OrderId,AttributeType=S --key-schema AttributeName=OrderId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 -> Option B
  4. Quick Check:

    Partition key = KeyType HASH + valid AttributeType [OK]
Quick Trick: Partition key must be KeyType HASH with valid attribute type [OK]
Common Mistakes:
MISTAKES
  • Using KeyType RANGE for partition key
  • Using invalid attribute types like Z
  • Mixing attribute and key schema order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes