Getting Started with Amazon DynamoDB
Welcome to the Amazon DynamoDB Getting Started Guide. This guide contains hands-on tutorials to help you learn about Amazon DynamoDB. We strongly encourage you to review this guide in this order:
Become familiar with the basic DynamoDB concepts on this page.
If you want to write programs that leverage DynamoDB, work through one of the language-specific tutorials in this Getting Started Guide. The sample code in these tutorials can run against either DynamoDB Local or the Amazon DynamoDB web service.
After you complete the exercises in this guide, we recommend that you read the Amazon DynamoDB Developer Guide. The Amazon DynamoDB Developer Guide provides more in-depth information about DynamoDB, including sample code and best practices.
Introduction to DynamoDB Concepts
This section briefly introduces some of the basic DynamoDB concepts. This helps you as you follow steps in the tutorials.
Similar to other database management systems, DynamoDB stores data in tables. A
table is a collection of data. For example, you could create
a table named
People, where you could store information about friends,
family, or anyone else of interest. You could also have a
to store information about vehicles that people drive.
Each table contains multiple items. An item is a group of
attributes that is uniquely identifiable among all of the other items. In a
People table, each item would represent one person. For a
Cars table, each item represents one vehicle. Items are
similar in many ways to rows, records, or tuples in relational database systems. In
DynamoDB, there is no limit to the number of items that you can store in a
Each item is composed of one or more attributes. An attribute
is a fundamental data element, something that does not need to be broken down any
Department item might have attributes such as
Manager, and so on.
An item in a
People table could contain attributes such as
FirstName, and so on.
Attributes in DynamoDB are similar in many ways to fields or columns in other database
When you create a table, in addition to the table name, you must specify the primary key of the table. As in other databases, a primary key in DynamoDB uniquely identifies each item in the table, so that no two items can have the same key. When you add, update, or delete an item in the table, you must specify the primary key attribute values for that item. The key values are required; you cannot omit them.
DynamoDB supports two different kinds of primary keys:
Partition Key—A simple primary key, composed of one attribute known as the partition key. DynamoDB uses the partition key's value as input to an internal hash function; the output from the hash function determines the partition where the item is stored. With a simple primary key, no two items in a table can have the same partition key value.
Partition Key and Sort Key—A composite primary key, composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key. DynamoDB uses the partition key value as input to an internal hash function; the output from the hash function determines the partition where the item is stored. All items with the same partition key are stored together, in sorted order by sort key value. With a composite primary key, it is possible for two items to have the same partition key value, but those two items must have different sort key values.
The partition key of an item is also known as its hash attribute. The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
The sort key of an item is also known as its range attribute. The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
In DynamoDB, you can read data in a table by providing primary key attribute values. If you want to read the data using non-key attributes, you can use a secondary index to do this. After you create a secondary index on a table, you can read data from the index in much the same way as you do from the table. By using secondary indexes, your applications can use many different query patterns, in addition to accessing the data by primary key values.
For more information, see Amazon DynamoDB: How It Works in the Amazon DynamoDB Developer Guide: