DynamoDB: Fundamentals and Data Model
What you'll learn: How AWS DynamoDB stores data using a serverless, schema-flexible table structure built around items and attributes.
What is DynamoDB?
DynamoDB is AWS's fully managed NoSQL database service. Unlike the relational databases you learned about in RDS, DynamoDB doesn't require you to provision servers, manage capacity planning, or worry about underlying infrastructure—it's serverless. You pay for what you use, and AWS handles scaling automatically.
The DynamoDB Data Model
Think of DynamoDB like a giant spreadsheet where each row can have different columns:
Tables are the top-level containers (like spreadsheet files). Each table holds related data.
Items are individual records in a table (like spreadsheet rows). An item is a collection of attributes that represent one entity—for example, one customer or one product.
Attributes are the fields within an item (like spreadsheet cells). Each attribute has a name and a value. Here's the key difference from relational databases: not every item needs the same attributes. One item might have five attributes, another might have ten completely different ones.
Schema Flexibility
DynamoDB is schema-less except for one requirement: every table must define a primary key to uniquely identify each item. Beyond that, you can add any attributes you want to any item. This flexibility makes DynamoDB ideal for evolving data models where different records might contain different information.
Example Structure
A Users table might have items like:
- Item 1:
{UserId: "123", Name: "Alice", Email: "alice@example.com"} - Item 2:
{UserId: "456", Name: "Bob", Age: 30, City: "Seattle"}
Notice how Item 2 has Age and City while Item 1 doesn't—both are valid.
Key Takeaway: DynamoDB is a serverless NoSQL database that organizes data into tables of items (records) with flexible attributes, requiring only a primary key definition while allowing each item to have its own unique set of fields.