What Is Amazon DynamoDB?

What is DynamoDB?
DynamoDB is the latest NoSql-database-as-a-service offering by Amazon. The design of DynamoDB is based on Amazon'sDynamo keyvalue store which is internally used by Amazon for their e-commerce platform. DynamoDB offers two main advantages over SimpleDB Unlike SimpleDB which has limits on request rate and total size (10GB) per domain, DynamoDB can theoretically be provisioned for infinite throughput capacity per table. This means that DynamoDB takes care of sharding your data. Second, DynamoDB offers faster and more predictable query performance by offering a restricted data model and utilizing solidstate drives for storage.
Let's take a look at DynamoDB's data model.
Data Model:

Tables, Items and Attributes
DynamoDB's data model consists of tables, items and attributes.
Each table is a collection of items and each item is a collection of attributes
An Attribute is simply a name-value pair, e.g., ("userId"=1234).
Consider for example a Users table where a user item may look like:
Users : "UserId"=1234 ,"Name"="Bilal Sheikh“ ,"City"="Waterloo“
Posts : "PostId"=345, "Version"=2

Primary Key, Composite Key and Indices
Each table must have a primary key attribute which is specified when the table is created.
The primary key attribute must have a value for all items and the value must be unique.
In our User table, UserId is the primary key attribute.
Instead of specifying a single attribute as the primary key, a composite primary
key can be specified on two attributes.
Hash index used for partitioning data is created for one of the attributes and a Range index is created for the second attribute of a composite key.
In our Posts model, a composite primary key of UserId and DateTime can be specified where the UserId will be the hash key and the DateTime will be the range key.
Both attributes of a composite key must have a value for all items.
Note: The data model is much more restricted than SimpleDB where indices are created automatically for all attributes.
The restricted data model allows for theoretically infinite scalability and fast get and put operations.
BENEFITS OF DYNAMODB
Fast, Consistent Performance
Amazon DynamoDB is designed to deliver consistent, fast performance at any scale for all applications.
Average service-side latencies are typically single-digit milliseconds. 
As your data volumes grow and application performance demands increase, Amazon DynamoDB uses automatic partitioning to meet your throughput requirements and deliver low latencies at any scale.

Highly Scalable
When creating a table, simply specify how much request capacity you require. If your throughput requirements change, simply update your table's request capacity using the AWS Management Console or the Amazon DynamoDB APIs. Amazon DynamoDB manages all the scaling behind the scenes, and you are still able to achieve your prior throughput levels while scaling is underway. 

Flexible
Amazon DynamoDB supports both document and key-value data structures, giving you the flexibility to design the best architecture that is optimal for your application. 

Event Driven Programming 
Amazon DynamoDB integrates with AWS Lambda to provide Triggers which enables you
to architect applications that automatically react to data changes. 

Fine-grained Access Control 
Amazon DynamoDB integrates with AWS Identity and Access Management (IAM) for fine-grained access control for users within your organization. You can assign unique security credentials to each user and control each user's access to services and resources. 

Fully Managed
Amazon DynamoDB is a fully managed cloud NoSQL database service – you simply create a database table, set your throughput, and let the service handle the rest.
You no longer need to worry about database management tasks such as hardware or software provisioning, setup and configuration, software patching, operating a reliable, distributed database cluster, or partitioning data over multiple instances as you scale.
INTRODUCTION TO DYNAMODB CONCEPTS
Tables
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 Cars table to store information about vehicles that people drive.

Items
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 table.

Attributes
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 further.
A Department item might have attributes such as DepartmentID, Name, Manager, and so on.
An item in a People table could contain attributes such as PersonID, LastName, FirstName, and so on. Attributes in DynamoDB are similar in many ways to fields or columns in other database management systems.

Primary Key
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.
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.
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.

Secondary Indexes
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.

BASIC DYNAMODB OPERATIONS
DynamoDB includes an interactive JavaScript shell, where you can get hands on experience with the DynamoDB API.
To use the shell, you enter JavaScript code on the left side, and then click the play button arrow (►) to run the code. The right side shows you the results.

Download DynamoDB for free using one of these links:
1) .tar.gz format: http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz

2) .zip format: http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.zip

Important Note: DynamoDB supports the Java Runtime Engine (JRE) version 6.x or newer; it does not run on older JRE versions

What's Next
How to install DynamoDB on Ubuntu - This guide will show how to install Amazon Dynamo Database on Ubuntu


Comments