Bird
0
0

Which of the following is the correct syntax to create a DynamoDB table with a partition key named 'UserId'?

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

    Partition key must be defined with AttributeType S (string) or N (number). Here, UserId is string (S).
  2. Step 2: Verify key schema

    Partition key uses KeyType HASH. aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 correctly uses HASH for UserId.
  3. Final Answer:

    Correct syntax with string UserId as HASH key -> Option B
  4. Quick Check:

    Partition key syntax = aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 [OK]
Quick Trick: Partition key uses KeyType HASH and correct AttributeType [OK]
Common Mistakes:
MISTAKES
  • Using KeyType RANGE for partition key
  • Missing attribute definitions
  • Wrong AttributeType for UserId

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes