Amazon DynamoDB Tutorial

In this section of the AWS tutorial, we will be discussing the concepts of Amazon DynamoDB Service. We will take a look at its features, working, and pricing. To begin with DynamoDB, there is a simple hands-on at the end of the blog.

Amazon DynamoDB Tutorial
 23rd Aug, 2019
 149 Views

What is AWS DynamoDB?

 AWS DynamoDB is a fully managed NoSQL database. In AWS DynamoDB no Database administration is required. Amazon DynamoDB automatically spreads the data and traffic for tables over a sufficient number of servers to handle throughput and storage requirements. JSON formatted documents can be stored as items in AWS DynamoDB.

Check this Intellipaat AWS video :

AWS DynamoDB tables are non-relational and are schema free. There are tables in Amazon DynamoDB and each table has several items (rows) and each item has Keys and Attributes (Columns).

Want to read more about AWS? Go through this AWS Tutorial!

Core Concepts of AWS DynamoDB

  • Tables
    • In Amazon DynamoDB, the collection of items is known as a table. A table in AWS DynamoDB is not a structured table with a fixed number of cells or columns.
  • Items
    • Each table in Amazon DynamoDB contains one or more than one items. Items are made up of a group of attributes that are uniquely identifiable.
  • Attributes
    • Attributes in AWS DynamoDB are fundamental data elements or values that reside in an item. Equivalent to data values that reside in a particular cell of a table in a relational database.

DynamoDB Working Use Case

There are a lot of use cases with AWS DynamoDB but for your understanding, a simple microservice data store use case is used.

As per the above illustration, consider a social media stream is incoming and a Lambda is triggered. To learn what is Lambda, check out this tutorial on Amazon Lambda. After the Lambda gets triggered the code for hashtag generation runs.

Get certified from top AWS course in London Now!

The hashtag data generated from the social media stream is stored in the AWS DynamoDB because it is a serverless store and provides consistent and fast performance. You can use the data stored in the Amazon DynamoDB to create a social media trend and analytics on it.

Amazon DynamoDB Features

 There are 3 main AWS DynamoDB Features available which makes it efficient to use from a business perspective.

  • Performance at Scale
  • Serverless
  • Enterprise-ready

Performance at Scale 

  • Real-time data processing
    • AWS DynamoDB stores it’s items in chronological time order. Whenever a change occurs in a particular item it can be captured and compared with other items
  • Microsecond latency
    • Even while receiving millions of requests per seconds, the time it takes to read will just be milliseconds to microseconds
  • Key value and document based
    • This flexible feature allows data to be in any structure the business needs. It could change according to the change in the storage structure of the business

Serverless 

  • Autoscaling
    • Whenever your websites request for some data increases or decreases, autoscaling feature will increase or decrease the size of the database in synchrony. This helps in maintaining costs for your database uses
  • Read/write modes
    • You can either set an on-demand mode or a provisioning mode.
    • In the on-demand mode, autoscaling feature will take care of provisioning new databases.
    • In the provisioning mode, you have to set tables, permissions, and also increase and decrease capacity

Are you preparing for AWS interview? Then here are trending AWS interview questions

Enterprise Ready

  • Encryption for data
    • Amazon DynamoDB encrypts customer data at REST which improves the security. They provide security by creating encryption keys using the AWS Key Management Service.
  • Point-in-time recovery
    • This prevents from accidental deletion or updation operations of your tables
    • There will be a continuous backup of your data up to a certain time period which you can use recover at any point of time.

AWS DynamoDB Pricing

Free tier eligible forever but the data content has to be lesser than 25 GB.

The pricing varies according to the region. Considering North Virginia as the default region, let us look at the price for each service under Amazon DynamoDB.

Get certified from top AWS course in Melbourne  Now!

On-Demand capacity mode

Data Storage

  • First 25 GB stored per month is free
  • $0.25 per GB-month thereafter

Read/Write Requests

  • Write request unit – $1.25 per million write request units
  • Read request units – $0.25 per million read request units

Backup and Restore

  • $0.20 per GB-month

Provisioned capacity mode

Data Storage

  • First 25 GB stored per month is free
  • $0.25 per GB-month thereafter

Read/Write Requests

  • Write capacity unit (WCU) – $0.00065 per WCU
  • Read capacity unit (RCU) – $0.00013 per RCU

Backup and Restore

  • $0.20 per GB-month

Hope this helps you and to learn more about Amazon Web Services keep reading the tutorial.

Hands-on: Creating a AWS DynamoDB table, inserting data to it, and querying it

 First, let’s create a AWS DynamoDB table.

Step 1: Log on to the AWS Management Console and go to AWS DynamoDB Service. To start with creating a Amazon DynamoDB table, click on “create table”

Step 2: First give a name for your table “Table name”, and then mention the primary key for your table “Primary key”.

Step 3: You can create as many tables as you like, and you can click on “Overview” to get all the information about the table.

We have now created a table called “Student”. Now let us insert some items in it.

Step 1: Click on “Items” and then choose “Create Item”.

Step 2: Now click on the plus symbol and choose to “Append” with a specified data type (eg. String). You can add any data type.

Step 3: Now add Field names and Values for the appended spaces. It will look like this after entering the data. After that hit the “Save” button.

Step 4: This is what the console displays after entering multiple items. Creating a table and inserting contents is this simple. You don’t need to do all the work, AWS console is designed to manage it.

We have created and inserted values into a AWS DynamoDB table called “Student” and mentioned “StdID” as the primary key. Now let us do some simple querying.

Step 1: Click on the “Add filter” button to start with querying. Now add filter attributes and values to make it more specific.

Step 2: In this query example, we are taking the query as “Name = Keanu” and all the items with the name “Keanu” are filtered and displayed.

Step 3: In this query example, we give the filter as “Address Contains ba”. This will filter all the Address field values which have the sequence “ba” in them.

Amazon DynamoDB is on the top 20 most used AWS services. As it is widely used, learning it adds value to you. Here, we have learned the concepts of AWS DynamoDB both theoretically and practically. Hope this helps you!

If you have any doubts or queries related to AWS, do post on AWS Community.

 

Related Articles

Leave a Reply

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