Design Tips & Common Mistakes

How to model data for DynamoDB, plus handy features like TTL and Streams.

1 min read

Start from your access patterns

Before creating a table, write down the questions your app will ask:

  1. "Get a note by ID"
  2. "List a user's notes, newest first"
  3. "Find a user by email"

Then design keys (and GSIs) so each question is a get_item or a query. This is the opposite of relational design, where you model the data first and write queries later.

Handy features

  • TTL (Time to Live): set an expiry timestamp attribute and DynamoDB deletes the item for free after that time. Great for sessions and temporary data.
  • Streams: a log of every change, which can trigger Lambda. Use it to send emails, update search indexes, or keep aggregates up to date.
  • Point-in-time recovery: continuous backups that let you restore to any second in the recovery window. Turn it on for important tables.

Common mistakes

MistakeBetter approach
Using Scan for everyday lookupsRedesign keys or add a GSI so you can Query
Low-variety partition key (e.g. status)High-cardinality keys like user or order IDs
Storing large files in itemsStore them in S3 and save the S3 key in the item
Forgetting about Decimal in PythonConvert before serializing to JSON

Key takeaways

  • List your access patterns first, then design keys so each one is a get or a query.
  • TTL auto-deletes expired items, and Streams let changes trigger Lambda.
  • Keep big files in S3 and turn on point-in-time recovery for important tables.

Check your understanding

Pick an answer to see the explanation.

  1. 1. You want user sessions to disappear automatically after 24 hours. Which feature helps?

Next in “Build a serverless AI app”
You finished DynamoDB. Continue with the Bedrock tutorial