Learn Amazon DynamoDB

AWS's serverless key-value and document database with single-digit-ms latency

19 lessons · 4 hours · 4 levels · covers Amazon DynamoDB 2012-08-10 API (boto3 1.40+)

Amazon DynamoDB is a fully managed NoSQL database on AWS that stores items by key and scales to virtually any traffic with predictable low latency and no servers to run. It powers shopping carts, sessions, game state, IoT and many serverless backends. Learning it means learning to design data around access patterns instead of joins.

Before you start

Amazon DynamoDB builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms12 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs16 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know19 lessons · 4 hours in total

The Amazon DynamoDB tree

Amazon DynamoDBWhat DynamoDB isWhat DynamoDB isPartition keys and sort keysPartition keys andsort keysAttribute types and boto3Attribute types andboto3Creating tables and DynamoDB LocalCreating tables andDynamoDB LocalPut, get, update and delete itemsPut, get, update anddelete itemsQuery an item collectionQuery an itemcollectionScan and paginationScan and paginationUpdate, condition and projection expressionsUpdate, conditionand projection expr…Conditional writes and optimistic lockingConditional writesand optimistic locki…Global and local secondary indexesGlobal and localsecondary indexesBatch reads and writesBatch reads andwritesCapacity modes and read consistencyCapacity modes andread consistencyDictionariesDictionariesModules and importsModules and importsfor and while loopsfor and while loopsExceptions in depthExceptions in depth
Essentials and Practical shown (12 of 19 lessons); the full list is below. Click a lesson to read it.

All 19 lessons, in order

Data model

  1. What DynamoDB is · Essentials · 8 min

    A fully managed key-value and document database: tables of items looked up by key, with no servers and near-unlimited scale.

  2. Partition keys and sort keys · Essentials · 12 min

    The primary key is a partition key alone or a partition key plus sort key; it decides where items live and how you can query them.

  3. Attribute types and boto3 · Essentials · 10 min

    DynamoDB's attribute types (string, number, binary, boolean, null, map, list, sets) and how boto3 maps them to Python.

  4. Creating tables and DynamoDB Local · Essentials · 12 min

    Create a table with boto3, choose on-demand billing, wait until it is active, and develop against DynamoDB Local.

Reading and writing

  1. Put, get, update and delete items · Essentials · 12 min

    The four single-item operations: put_item, get_item, update_item and delete_item, all addressed by the full primary key.

  2. Update, condition and projection expressions · Practical · 14 min

    Write UpdateExpressions with SET, REMOVE, ADD and DELETE, plus placeholders for names and values.

  3. Conditional writes and optimistic locking · Practical · 12 min

    Make writes succeed only if the item is in an expected state: create-only puts, guarded updates and version numbers.

  4. Batch reads and writes · Practical · 10 min

    Read up to 100 items and write up to 25 per request with BatchGetItem and BatchWriteItem, and retry unprocessed items.

  5. Transactions · Advanced · 14 min

    Group up to 100 actions across items and tables into an all-or-nothing TransactWriteItems or a consistent TransactGetItems.

Queries and indexes

  1. Query an item collection · Essentials · 12 min

    Query all items for one partition key, narrow with sort key conditions, sort ascending or descending and limit results.

  2. Scan and pagination · Practical · 12 min

    Read a whole table with Scan, page through any result with LastEvaluatedKey, and use parallel scans when you must.

  3. Global and local secondary indexes · Practical · 14 min

    Add GSIs and LSIs to query by other attributes, choose projections, and understand their consistency and limits.

Capacity and operations

  1. Capacity modes and read consistency · Practical · 14 min

    On-demand versus provisioned capacity, how reads and writes are metered, throttling, and eventual versus strong consistency.

  2. Partitions, hot keys and adaptive capacity · Expert · 15 min

    How DynamoDB stores data in partitions, the per-partition throughput limits, and how adaptive capacity and splits handle heat.

  3. Item size, caching and cost control · Expert · 14 min

    Work within the 400 KB item limit, offload large blobs to S3, cache with DAX, and keep read and write costs predictable.

Data modelling

  1. Designing from access patterns · Advanced · 18 min

    Model a DynamoDB table by listing access patterns first, then shaping keys, often with several entity types in one table.

  2. Sparse indexes, overloading and sharding · Advanced · 16 min

    Advanced key patterns: sparse GSIs, overloaded GSI keys, inverted indexes and write sharding for hot partitions.

Streams and global scale

  1. Streams and TTL · Advanced · 14 min

    React to every item change with DynamoDB Streams and Lambda, and expire items automatically with Time to Live.

  2. Global tables and multi-Region · Expert · 14 min

    Replicate a table across AWS Regions, understand conflict resolution and consistency choices, and plan failover.