DynamoDB Primer
A no-nonsense guide to Amazon's fully managed NoSQL database. Learn the core primitives — tables, items, primary keys, and capacity modes — so you can model data with confidence.
Tables, Items, and Attributes
A table holds items. An item is a collection of attributes — think JSON document. Every item must have a primary key. There are no fixed schemas; each item can have a different shape.
Primary Keys
Partition key — simple, single-attribute key. DynamoDB hashes it to determine the storage partition.
Composite key — partition key plus sort key. Items with the same partition key are stored together and ordered by the sort key. Enables range queries.
Capacity Modes
On-demand — pay per request. Scales instantly. Best for spiky or unknown workloads.
Provisioned — specify read/write capacity units. Predictable cost. Use auto-scaling to handle variance.
Secondary Indexes
Query by attributes other than your primary key. Global secondary indexes (GSI) can have a different partition key. Local secondary indexes (LSI) share the table's partition key but use a different sort key.
Single-Table Design
Store multiple entity types in one table. Use prefixed partition keys and overloaded sort keys. A single query fetches related data — no joins needed. The gold standard for serverless applications.
Pro tip: Always design your access patterns first. DynamoDB rewards you when you model for how you read, not how you store.