Stop 07 · NoSQL DatabasesTopics · 12/12

DynamoDB (Overview)

Part of the Backend Developer Roadmap

In short

DynamoDB is AWS's fully managed NoSQL database. No servers to patch, it scales for you, and you can pay per request. The catch: you design around your queries from day one.

Amazon's fully managed, serverless NoSQL key-value/document database — popular for AWS-based serverless architectures needing predictable low-latency access at scale.

The blob receives a plate through a hostel mess hatch from a hidden kitchen.

Think of it like this

The hostel mess hatch

At the mess you don't run the kitchen. You walk up to the hatch, ask for something on the menu, and a plate slides out. The kitchen scales up for exam week on its own. But you can only order what's on the menu. DynamoDB works like that hatch.

Watch it happen

One table, keyed for queries

USER#7 | PROFILE
0
USER#7 | ORDER#1042
1
USER#7 | ORDER#1043
2
USER#9 | PROFILE
3

1/5Each item has a partition key (PK) and a sort key (SK). Users and orders share one table.

The big ideas

What you need to know

Fully managed

AWS runs the servers, replication and backups. You create a table and start reading and writing.

Partition and sort keys

The partition key spreads items across storage; the sort key orders items inside a partition.

Query, not Scan

Query uses keys and is fast. Scan reads the whole table and gets slow and expensive.

Secondary indexes

A GSI gives the table another key, so a second access pattern can also use Query.

See it in code

Walk through the code

ts
1import { DynamoDBClient } from "@aws-sdk/client-dynamodb";2import { DynamoDBDocumentClient, QueryCommand } from "@aws-sdk/lib-dynamodb";3 4const db = DynamoDBDocumentClient.from(new DynamoDBClient({ region: "ap-south-1" }));5 6const { Items } = await db.send(new QueryCommand({7  TableName: "app",8  KeyConditionExpression: "PK = :pk AND begins_with(SK, :sk)",9  ExpressionAttributeValues: { ":pk": "USER#7", ":sk": "ORDER#" },10  ScanIndexForward: false,11  Limit: 10,12}));

1/3The document client lets you use plain JS objects. ap-south-1 is the Mumbai region.

Run it with AWS credentials set up, or point the client at DynamoDB Local to practise for free.

Save yourself the pain

Common mistakes

Oops

Designing tables like SQL and planning to Scan with filters.

Do this instead

Scan reads everything and you pay for all of it. Design keys and GSIs so each screen is a Query.

Oops

Choosing a partition key with only a few possible values, like status.

Do this instead

A few hot keys overload a few partitions. Pick keys with lots of variety, like userId.

Your mission

DynamoDB Local

~30 min

Quick check

You need 'all orders for user 7, newest first'. What's the DynamoDB-friendly design?

Go deeper

  1. 1Read AWS's documentation on DynamoDB's single-table design philosophy.
  2. 2Understand its pricing model (provisioned/on-demand capacity) at a high level.
  3. 3Compare it to self-hosted MongoDB in terms of operational overhead.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge