Bird
0
0

Which JSON snippet correctly defines the key schema and attribute definitions?

hard📝 Application Q9 of 15
AWS - DynamoDB
You want to create a DynamoDB table with a partition key named 'SessionId' of type string and a sort key named 'CreatedAt' of type number. Which JSON snippet correctly defines the key schema and attribute definitions?
A{\"AttributeDefinitions\": [{\"AttributeName\": \"SessionId\", \"AttributeType\": \"S\"}, {\"AttributeName\": \"CreatedAt\", \"AttributeType\": \"N\"}], \"KeySchema\": [{\"AttributeName\": \"SessionId\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"CreatedAt\", \"KeyType\": \"RANGE\"}]}
B{\"AttributeDefinitions\": [{\"AttributeName\": \"SessionId\", \"AttributeType\": \"N\"}, {\"AttributeName\": \"CreatedAt\", \"AttributeType\": \"S\"}], \"KeySchema\": [{\"AttributeName\": \"SessionId\", \"KeyType\": \"RANGE\"}, {\"AttributeName\": \"CreatedAt\", \"KeyType\": \"HASH\"}]}
C{\"AttributeDefinitions\": [{\"AttributeName\": \"SessionId\", \"AttributeType\": \"S\"}], \"KeySchema\": [{\"AttributeName\": \"SessionId\", \"KeyType\": \"HASH\"}]}
D{\"AttributeDefinitions\": [{\"AttributeName\": \"SessionId\", \"AttributeType\": \"S\"}, {\"AttributeName\": \"CreatedAt\", \"AttributeType\": \"N\"}], \"KeySchema\": [{\"AttributeName\": \"CreatedAt\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"SessionId\", \"KeyType\": \"RANGE\"}]}
Step-by-Step Solution
Solution:
  1. Step 1: Match attribute types to keys

    Partition key 'SessionId' is string (S), sort key 'CreatedAt' is number (N).
  2. Step 2: Verify key schema order

    Partition key must be HASH, sort key must be RANGE in correct order.
  3. Final Answer:

    JSON with SessionId as HASH string and CreatedAt as RANGE number -> Option A
  4. Quick Check:

    Correct attribute and key types = {\"AttributeDefinitions\": [{\"AttributeName\": \"SessionId\", \"AttributeType\": \"S\"}, {\"AttributeName\": \"CreatedAt\", \"AttributeType\": \"N\"}], \"KeySchema\": [{\"AttributeName\": \"SessionId\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"CreatedAt\", \"KeyType\": \"RANGE\"}]} [OK]
Quick Trick: Partition key = HASH, sort key = RANGE with matching types [OK]
Common Mistakes:
  • Swapping HASH and RANGE keys
  • Mismatching attribute types
  • Omitting sort key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes