Bird
0
0

Given a DynamoDB table with primary key "UserID", what happens if you try to add two items with the same UserID but different attributes?

medium📝 service behavior Q13 of 15
AWS - DynamoDB
Given a DynamoDB table with primary key "UserID", what happens if you try to add two items with the same UserID but different attributes?
ABoth items are stored separately
BThe table creates a duplicate primary key
CAn error is thrown and no item is added
DThe second item overwrites the first item
Step-by-Step Solution
Solution:
  1. Step 1: Understand primary key uniqueness

    In DynamoDB, the primary key must be unique for each item in the table.
  2. Step 2: Effect of duplicate primary key

    If you add an item with an existing primary key, it replaces the old item with the new one.
  3. Final Answer:

    The second item overwrites the first item -> Option D
  4. Quick Check:

    Duplicate key = overwrite existing item [OK]
Quick Trick: Duplicate primary keys overwrite existing items [OK]
Common Mistakes:
MISTAKES
  • Thinking both items are stored separately
  • Expecting an error on duplicate keys
  • Assuming duplicates are allowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes