Amazon DynamoDB for Beginners: NoSQL Tables, Keys, Capacity, Indexes, Backups and Common Patterns

AWS Technical Essentials 50 min min read Updated: Nov 17, 2026 Beginner
Amazon DynamoDB for Beginners: NoSQL Tables, Keys, Capacity, Indexes, Backups and Common Patterns
Beginner Topic 2 of 3

SQL vs NoSQL

Relational (RDS)DynamoDB (NoSQL)
Data shapeTables with fixed columns, joinsItems with flexible attributes, no joins
ScalingMostly vertical, read replicasHorizontal, almost unlimited
SpeedDepends on queries and sizeSingle-digit millisecond at any scale
ManagementInstances, patches, backupsServerless, no servers
Best forComplex queries and transactionsKey lookups, high traffic, sessions, carts, IoT, leaderboards

Core Ideas

TermMeaning
TableCollection of items
ItemOne record (like a row), up to 400 KB
AttributeA field in an item (like a column), can differ between items
Partition keyRequired key. DynamoDB hashes it to decide where data is stored
Sort keyOptional second key to keep items with the same partition key in order
Primary keyPartition key alone, or partition key + sort key. Must be unique per item
json { "UserId": "u-100", "OrderId": "2026-11-17#0001", "Total": 499, "Items": [{"sku": "A1", "qty": 2}], "Status": "SHIPPED" }

Here UserId is the partition key and OrderId is the sort key, so you can quickly fetch all orders of one user in date order.

Create a Table and Use It

bash aws dynamodb create-table --table-name Orders \ --attribute-definitions AttributeName=UserId,AttributeType=S AttributeName=OrderId,AttributeType=S \ --key-schema AttributeName=UserId,KeyType=HASH AttributeName=OrderId,KeyType=RANGE --billing-mode PAY_PER_REQUEST aws dynamodb put-item --table-name Orders --item '{"UserId":{"S":"u-100"},"OrderId":{"S":"2026-11-17#0001"},"Total":{"N":"499"},"Status":{"S":"NEW"}}' aws dynamodb get-item --table-name Orders --key '{"UserId":{"S":"u-100"},"OrderId":{"S":"2026-11-17#0001"}}' aws dynamodb query --table-name Orders --key-condition-expression "UserId = :u" --expression-attribute-values '{":u":{"S":"u-100"}}' aws dynamodb update-item --table-name Orders --key '{"UserId":{"S":"u-100"},"OrderId":{"S":"2026-11-17#0001"}}' \ --update-expression "SET #s = :v" --expression-attribute-names '{"#s":"Status"}' --expression-attribute-values '{":v":{"S":"SHIPPED"}}' aws dynamodb delete-item --table-name Orders --key '{"UserId":{"S":"u-100"},"OrderId":{"S":"2026-11-17#0001"}}'
python import boto3 from boto3.dynamodb.conditions import Key table = boto3.resource("dynamodb").Table("Orders") table.put_item(Item={"UserId": "u-100", "OrderId": "2026-11-17#0002", "Total": 250, "Status": "NEW"}) resp = table.query(KeyConditionExpression=Key("UserId").eq("u-100")) for item in resp["Items"]: print(item["OrderId"], item["Status"])

Query vs Scan

  • Query: fetch items by partition key (and optionally sort key conditions). Fast and cheap
  • Scan: reads the whole table. Slow and costly on big tables. Avoid in normal app paths
  • Design your keys around your access patterns (the questions your app asks)

Capacity Modes

ModeHow it worksChoose when
On-demandPay per read and write request. No planning. Handles spikesNew or unpredictable traffic, learning
ProvisionedYou set read and write capacity (RCU/WCU). Can use auto scalingSteady, predictable traffic (cheaper)
  • RCU: read capacity unit. WCU: write capacity unit
  • Too many requests to one partition can cause throttling (ProvisionedThroughputExceededException). Pick keys with many different values to spread load

Secondary Indexes

IndexMeaning
GSI (Global Secondary Index)A different partition and sort key for another access pattern. Has its own capacity. Can be added any time
LSI (Local Secondary Index)Same partition key, different sort key. Must be created with the table

Example: the Orders table is by UserId. To search orders by Status, create a GSI with Status as partition key.

Helpful Features

  • TTL (time to live): automatically deletes expired items (sessions, temporary data) for free
  • DynamoDB Streams: ordered log of item changes. Trigger Lambda functions
  • Point-in-time recovery (PITR) restores to any second in the last 35 days, plus on-demand backups
  • Global tables: multi-Region, multi-active replication
  • DAX: in-memory cache that gives microsecond reads
  • Transactions: all-or-nothing writes across items
  • Encryption at rest is always on (KMS)
  • Access control with IAM, including fine-grained access per item
  • PartiQL: SQL-like queries

When to Choose DynamoDB

Great forNot ideal for
Shopping carts, sessions, user profiles, gaming scores, IoT data, serverless appsComplex joins, ad hoc reporting, many unknown query shapes

Practice

  1. Create the Orders table in on-demand mode and add three items
  2. Query all orders for one user and then try a scan
  3. Add a GSI on Status and query by it
  4. Turn on TTL with an expiresAt attribute
  5. Enable PITR and read how restore works

Conclusion

DynamoDB is a fully managed, serverless NoSQL database. Choose partition and sort keys from your access patterns, use query instead of scan, pick on-demand or provisioned capacity, add indexes for extra patterns, and use TTL, streams, PITR and global tables as needed.

Quick Summary: SQL vs NoSQL; core ideas; table and CRUD; query vs scan; capacity; indexes; features; fit.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators