Thuta Learning
AdvancedDevOpsbeginner

DynamoDB Basics

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand DynamoDB Basics without any of the intimidation
  • Get comfortable running things yourself in the AWS CLI/Console
  • Be ready to apply this concept in a real project right away

Let's think about this for a second

RDS (from the Intermediate chapter) is a relational database (tables, schema, SQL queries) — DynamoDB, on the other hand, is a NoSQL database with no fixed schema required (each item can have different attributes). You do need to design your Primary Key (Partition Key, optional Sort Key) up front, but the rest of your attributes can stay flexible. DynamoDB auto-scales and can be accessed from a Lambda function with millisecond-level latency — it's the most commonly used database layer in serverless applications (Lambda + API Gateway + DynamoDB).

Let's connect this to a real scenario

Create a 'Users' DynamoDB table with `userId` as the Partition Key, and you can flexibly add attributes (name, email, or custom fields) per user — a Lambda function (from Advanced lesson 2) can use the DynamoDB SDK to run `PutItem`/`GetItem` operations with millisecond-level latency.

Let's look at this together

bash
# Create a DynamoDB table with userId as the partition key
aws dynamodb create-table \
  --table-name Users \
  --attribute-definitions AttributeName=userId,AttributeType=S \
  --key-schema AttributeName=userId,KeyType=HASH \
  --billing-mode PAY_PER_REQUEST

# Insert an item
aws dynamodb put-item \
  --table-name Users \
  --item '{"userId": {"S": "user-1"}, "name": {"S": "Aye Aye"}}'
You should see
$ aws dynamodb get-item --table-name Users --key '{"userId": {"S": "user-1"}}'
{"Item": {"userId": {"S": "user-1"}, "name": {"S": "Aye Aye"}}}

Try it in 5 minutes

Create a 'Users' DynamoDB table and try putting/getting a couple of items — write two sentences on how this concept differs from the RDS lesson (Intermediate).

A quick word of caution

When designing a DynamoDB table, you need to decide your access patterns (what queries you'll be running) before choosing a Primary Key — unlike RDS, you can't just 'add an index later' as easily in NoSQL.

Easy traps

  • Choosing a low-cardinality value (like status: 'active'/'inactive') as the Partition Key instead of a well-distributed value (userId, orderId) — this crams traffic onto just a few partitions and can tank performance
  • Using DynamoDB for a use case that needs complex relational queries (multi-table JOINs) — NoSQL query patterns don't work like RDS/SQL

Now try it yourself

Create a 'Users' DynamoDB table and try putting/getting a couple of items — write two sentences on how this concept differs from the RDS lesson (Intermediate).

You'll know it worked when: $ aws dynamodb get-item --table-name Users --key '{"userId": {"S": "user-1"}}' {"Item": {"userId": {"S": "user-1"}, "name": {"S": "Aye Aye"}}}

DynamoDB Basics | Thuta Learning