Updated on 26th Oct, 21 2304 Views
 

What is AWS DynamoDB?

AWS DynamoDB is a fully managed NoSQL database. In it, no Database administration is required. It 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 AWS DynamoDB Video tutorial Video on Youtube:

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

In the next section of this AWS DynamoDB tutorial, we will learn about Accessing Amazon DynamoDB.

 

Accessing Amazon DynamoDB

Accessing DynamoDB is easy and can be done by any of the following three methods:

Common Line Interface (CLI): This method is very simple, you can open your command prompt and type the relevant commands and access the table. With the help of CLI, you can control multiple AWS services from the command line. It also helps you automate the scripts.

AWS Management Console: The console displays an introductory screen that promptly directs you to create a table. Further, you can perform operations, such as creation, updating, and deletion of tables, through the console. It allows you to perform a wide range of operations including monitoring recent alerts, service health, and the latest DynamoDB news on the DynamoDB dashboard. 

API:  While AWS Console and CLI are used to interactively work with Amazon DynamoDB, to get the most out of DynamoDB, you can write application code by using AWS SDKs. AWS SDK offers a wide range of support services in DynamoDB in Java, JavaScript in the browser, .NET, Node.js, Ruby, C++, iOS, etc.

 

AWS DynamoDB API

DynamoDB offers a wide range of powerful API tools for table manipulation, data reads, and data modification. The following are the APIs operations that you need to use to work with Amazon DynamoDB:

  • Control plane
  • Data plane
  • DynamoDB streams

Let us discuss each one of them one by one:

  1. Control plane: Control plane allows you to create and manage DynamoDB tables. It is also used to work with streams, indexes, and other objects that are dependent on tables.

    You can perform the following operations in DynamoDB with the help of a control plane:

    CreateTable: It allows you to create tables. With the help of this, you can create one or more secondary indexes and enable DynamoBD Streams for the table.

    DeleteTable: It removes a table and all of its dependent objects from DynamoDB.

    DescribeTable: It returns information about a table including primary key schema, throughput settings, and index information.

    UpdateTable: It modifies the settings of a table or its indexes, creates or removes new indexes on a table, or modifies DynamoDB streams settings.

    ListTables: It returns the names of all tables that are present in the list.
  2. Data plane: Data plane operations allow you to create, read, and update data in tables. You can use PartiQL (SQL-Compatible Query Language for Amazon DynamoDB) to perform CRUD operations. You can also use DynamoDB classic CRUD APIs that separate each operation into a distinct API call.

    i) Creating Data
    PutItem: It writes a single item in a table. In this, you only have to specify the primary key attributes but not other attributes.
    BatchWriteItem: This is more efficient than calling PutItem multiple times because BatchWriteItem allows you to put 25 items in the table at once. Similarly, it can be used for deleting multiple items from one or more tables.

    ii) Reading Data
    GetItem: It retrieves a single item from a table or just a subset of its attributes. It also specifies the primary key for the item that you want.
    BatchGetItem: This is more efficient than calling GetItem multiple times as BatchGetItem retrieves up to 100 items from one or more tables.
    Query: It retrieves all items having a specific partition key. You can retrieve entire items or just a subset of their attributes.
    Scan: With the help of this, you can retrieve all items in the specified table or index. In addition to this, you can apply a filtering condition to return only the values that you need.

    iii) Updating Data
    UpdateItem: It modifies one or more attributes in an item with the help of a specific attribute in the item. You can also add new attributes and modify or remove existing attributes.

    iv) Deleting Data
    DeleteItem: This deletes a single item from a table with the help of a specific primary key.
    BatchWriteItem: It deletes up to 25 items from one or more tables. This is more efficient than DeletItem because you can collectively delete a large chunk of items from the table.
  3. DynamoDB Streams: With the help of DynamoDB Streams, you can enable or disable a stream on a table and allow access to data modification records contained in a stream.

    It has the following types of streams:
    ListStreams: It returns a list of all your streams or just the stream for a specific table.
    DescribeStream: It returns information about a stream such as its Amazon Resource Name (ARN) and where your application can begin reading the first few stream records.
    GetShardIterator: It returns a shared iterator, a data structure used to retrieve records from the stream.
    GetRecords: Retrieves one or more stream records by using a given shard iterator. 

In the next section of this AWS DynamoDB tutorial, we will learn about working use cases.

 

AWS DynamoDB Working Use Case

There are a lot of use cases with AWS DynamoDB but for your understanding, a simple microservice datastore 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 by the 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 that make it efficient to use from a business perspective.

AWS11
  • Performance at Scale
  • Serverless
  • Enterprise-ready

Performance at Scale 

  • Real-time data processing
    • AWS DynamoDB stores its 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 second, 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

Certification in Cloud & Devops

Serverless

  • Autoscaling
    • Whenever your website’s request for some data increases or decreases, the 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, the 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 interviews? Then here are trending AWS interview questions!

Enterprise Ready

  • Encryption for data
    • Amazon DynamoDB encrypts customer data at REST which improves security. They provide security by creating encryption keys using the AWS Key Management Service.
  • Point-in-time recovery
    • This prevents 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 in time.

In the next section of this Amazon DynamoDB tutorial, we will take a look at the pricing and costs.

 

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 by the 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

Let’s get started with AWS DynamoDB!

Become a Cloud and DevOps Architect

In the next section of this Amazon DynamoDB tutorial, we will take a look at some Case studies of AWS DynamoDB

 

Amazon DynamoDB: Case Studies

DynamoDB offers some of the best features such as built-in security, backup and restores, and in-memory caching. Considering its high reliability, many small, as well as large companies, use DynamoDB. 

Here are a few examples of some of the companies that benefit from using DynamoDB: 

Nexon: Nexon used Amazon DynamoDB as their primary database for their superhit game HIT. Amazon DynamoDB helped Nexon to deliver steady latency to provide an excellent mobile gaming experience.

MLB Advanced Media (MLBAM): Amazon DynamoDB helped MLBAM to scale up the support for games on a single day. The company also stated that DynamoDB helped them to power queries and support for fast data retrieval.

Expedia: With the help of Amazon DynamoDB, Expedia was able to collect data for test-and-learn experiments. DynamoDB made data monitoring very easy and also helped in smoothly scaling it further. 

 

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

First, Now in this AWS DynamoDB tutorial, let’s create an AWS DynamoDB table.

Step 1: Log on to the AWS Management Console and go to AWS DynamoDB Service. To start with creating an 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 an 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 in the top 20 most used AWS services. As it is widely used, learning adds value to you. In this AWS DynamoDB tutorial, 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 a post on AWS Community.

Course Schedule

Name Date
AWS Certification 2021-11-27 2021-11-28
(Sat-Sun) Weekend batch
View Details
AWS Certification 2021-12-04 2021-12-05
(Sat-Sun) Weekend batch
View Details
AWS Certification 2021-12-11 2021-12-12
(Sat-Sun) Weekend batch
View Details

Leave a Reply

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

Looking for 50% Salary Hike ?

Speak to our course Advisor Now !

Related Articles

Associated Courses

Subscribe to our newsletter

Signup for our weekly newsletter to get the latest news, updates and amazing offers delivered directly in your inbox.