What Is a DynamoDB

Before writing a single line of code with DynamoDB, you need to understand its core vocabulary. These concepts appear in every DynamoDB tutorial, documentation page, and job interview. Understand them well, and everything else becomes easier.

The Big Picture: How DynamoDB Organizes Data

Imagine a warehouse full of labeled filing boxes. Each box is a table. Inside each box are individual folders — these are items. Each folder contains multiple sheets of paper with facts written on them — these are attributes.

That warehouse metaphor maps directly to DynamoDB:

  • Warehouse → DynamoDB Service
  • Filing Box → Table
  • Folder → Item
  • Sheet of Paper → Attribute

Table

A table is the top-level container for your data. You create one table per type of data — for example, a Users table, an Orders table, or a Products table.

Unlike SQL tables, a DynamoDB table does not enforce a rigid structure on every item it holds. Two items in the same table can have completely different attributes.

Item

An item is a single record inside a table — similar to a row in a spreadsheet, but without the rigid column constraint. Each item is uniquely identified by its primary key.

A Users table might store one item like this:

{
  "UserID": "U001",
  "Name": "Priya Sharma",
  "City": "Mumbai",
  "Age": 28
}

A second item in the same table might look like this:

{
  "UserID": "U002",
  "Name": "Rahul Mehta",
  "Email": "rahul@example.com",
  "Subscribed": true
}

Notice that the second item has different attributes. DynamoDB allows this. The only required attribute is the primary key.

Attribute

An attribute is a single piece of data within an item — like a field in a form. Each attribute has a name and a value. For example, "City": "Mumbai" is one attribute. The name is City and the value is Mumbai.

Attributes can hold different types of data: text, numbers, true/false values, lists, and even nested objects.

Primary Key

Every item in a DynamoDB table must have a primary key. This key uniquely identifies the item — no two items in the same table can share the same primary key.

Think of it like a vehicle registration number. No two vehicles on the road share the same number. The primary key plays the same role for DynamoDB items.

There are two types of primary keys in DynamoDB:

Partition Key (Simple Primary Key)

A single attribute acts as the unique identifier. For example, UserID can be the partition key in a Users table. Every item must have a different UserID.

Composite Primary Key (Partition Key + Sort Key)

Two attributes together form the key. The partition key groups related items, and the sort key orders them within that group. For example, an Orders table might use UserID as the partition key and OrderDate as the sort key. A single user can have many orders, each with a different date.

Diagram: Table, Items, and Attributes

+---------------------------------------------------------+
| TABLE: Orders                                           |
|                                                         |
|  ITEM 1                      ITEM 2                     |
|  +-----------------------+   +-----------------------+  |
|  | UserID: "U001" (PK)   |   | UserID: "U001" (PK)   |  |
|  | OrderDate: "2024-01"  |   | OrderDate: "2024-03"  |  |
|  | (Sort Key)            |   | (Sort Key)            |  |
|  | Product: "Laptop"     |   | Product: "Mouse"      |  |
|  | Amount: 85000         |   | Amount: 1200          |  |
|  +-----------------------+   +-----------------------+  |
+---------------------------------------------------------+

In this diagram, UserID + OrderDate together form the composite primary key. User U001 has two orders, each with a unique date.

Read and Write Capacity Units

DynamoDB measures database activity in units:

  • Read Capacity Unit (RCU): One strongly consistent read of an item up to 4 KB in size per second.
  • Write Capacity Unit (WCU): One write of an item up to 1 KB in size per second.

You either set these limits manually (provisioned mode) or let DynamoDB scale them automatically (on-demand mode). This is covered in detail in the Capacity Modes topic.

Indexes

By default, you can only query a DynamoDB table using the primary key. Indexes let you query data using other attributes. DynamoDB supports two types of indexes: Local Secondary Indexes (LSI) and Global Secondary Indexes (GSI). These are covered in their own dedicated topics later in this course.

Streams

DynamoDB Streams capture a time-ordered sequence of every change made to items in a table. You can use streams to trigger automated actions — for example, sending a confirmation email whenever a new order item is added to the Orders table.

Summary

ConceptWhat It Means
TableContainer for all items of one data type
ItemA single record inside a table
AttributeA single field (name + value) within an item
Primary KeyUnique identifier for each item
Partition KeySingle-attribute primary key
Sort KeySecond part of a composite primary key
RCU / WCUUnits that measure read and write throughput
IndexAllows queries on non-primary-key attributes
StreamCaptures every change made to table items

Leave a Comment

Your email address will not be published. Required fields are marked *