Grab Deal : Flat 30% off on live classes + 2 free self-paced courses! - SCHEDULE CALL

- AWS Blogs -

What Is Amazon DynamoDB? How Does It Work?



Introduction

In the vast era of information technology, web, mobile, gaming, and Internet of Things are the top trends that are popular among the modern generation. Amazon’s DynamoDB is the top database solution among cloud computing environment. All the applications that need low-latency data access, DynamoDb is the solution. In this blog post, we will learn the fundamentals of DynamoDB, it's working, and a few of the fundamental concepts.

Accessing Amazon DynamoDB

You can access Amazon DynamoDB by using three different methods: -

  • Console (https://console.aws.amazon.com/dynamodb/home)
  • Command Line Interface (Simply open your command prompt and type the related commands to access the table)
  • API (You can use AWS SDK’s to access DynamoDB which supports a variety of languages like Java, Javascript, Python, .Net, PHP, etc.)

Features of Amazon DynamoDB

  • Using DynamoDB, developers can easily develop scalable cloud-based applications
  • AWS can easily achieve data retrieval in single-digit milliseconds
  • DevOps need not worry about managing the high availability and durability of data because DynamoDB automatically replicates it synchronously across multiple AWS Availability Zones (AZs)
  • DynamoDB can be provisioned according to the number of write units and several read units allocated
  • The user’s database table always remain available based on provisioned throughput requirements like read-write units per second
  • DynamoDB utilizes JSON as a transport protocol
  • Hashkeys are used for the data partitioning in DynamoDB
  • NoSQL and Big Data are the technologies that work together because they both share the same allocated and scalable side-to-side structure of the database

These are some of the key features of Amazon RDS. However, if you're preparing to sit for your Cloud Computing certification? We recommend you to go through various AWS blogs available on the JanBask Training that has been curated to help you become Industry-ready!

Amazon DynamoDB API

DynamoAPI offers a wide set of actions that require permissions. To set permissions, you have to establish the actions permitted, resources permitted, and conditions of each.

For example − dynamodb:CreateTable

You can also employ condition keys to filter permissions.

API Operation Necessary Permission
BatchGetItem dynamodb:BatchGetItem
BatchWriteItem dynamodb:BatchWriteItem
CreateTable dynamodb:CreateTable
DeleteItem dynamodb:DeleteItem
DeleteTable dynamodb:DeleteTable
DescribeLimits dynamodb:DescribeLimits
DescribeReservedCapacity dynamodb:DescribeReservedCapacity
DescribeReservedCapacityOfferings dynamodb:DescribeReservedCapacityOfferings
DescribeStream dynamodb:DescribeStream
DescribeTable dynamodb:DescribeTable
GetItem dynamodb:GetItem
GetRecords dynamodb:GetRecords
GetShardIterator dynamodb:GetShardIterator
ListStreams dynamodb:ListStreams
ListTables dynamodb:ListTables
PurchaseReservedCapacityOfferings dynamodb:PurchaseReservedCapacityOfferings
PutItem dynamodb:PutItem
Query dynamodb:Query
Scan dynamodb:Scan
UpdateItem dynamodb:UpdateItem
UpdateTable dynamodb:UpdateTable

Note: AWS is a big domain with multiple job roles. If you are a beginner looking to excel in your career in AWS. Check out the best High-Paying Cloud Certifications in 2022 that can remarkably boost your career. 

Resources

In the following table, you can view the resources associated with each permitted API action −

API Operation Resource
BatchGetItem arn:aws:dynamodb:region:account-id:table/table-name
BatchWriteItem arn:aws:dynamodb:region:account-id:table/table-name
CreateTable arn:aws:dynamodb:region:account-id:table/table-name
DeleteItem arn:aws:dynamodb:region:account-id:table/table-name
DeleteTable arn:aws:dynamodb:region:account-id:table/table-name
DescribeLimits arn:aws:dynamodb:region:account-id:*
DescribeReservedCapacity arn:aws:dynamodb:region:account-id:*
DescribeReservedCapacityOfferings arn:aws:dynamodb:region:account-id:*
DescribeStream arn:aws:dynamodb:region:account-id:table/table-name/stream/stream-label
DescribeTable arn:aws:dynamodb:region:account-id:table/table-name
GetItem arn:aws:dynamodb:region:account-id:table/table-name
GetRecords arn:aws:dynamodb:region:account-id:table/table-name/stream/stream-label
GetShardIterator arn:aws:dynamodb:region:account-id:table/table-name/stream/stream-label
ListStreams arn:aws:dynamodb:region:account-id:table/table-name/stream/*
ListTables *
PurchaseReservedCapacityOfferings arn:aws:dynamodb:region:account-id:*
PutItem arn:aws:dynamodb:region:account-id:table/table-name
Query arn:aws:dynamodb:region:account-id:table/table-name arn:aws:dynamodb:region:account-id:table/table-name/index/index-name
Scan arn:aws:dynamodb:region:account-id:table/table-name arn:aws:dynamodb:region:account-id:table/table-name/index/index-name
UpdateItem arn:aws:dynamodb:region:account-id:table/table-name
UpdateTable arn:aws:dynamodb:region:account-id:table/table-name

As an instance, the classification of DynamoDB is as follows: -

  • Control Plane (It is responsible for creating and managing DynamoDB table)
    • Create Table
    • Describe Table
    • List Table
    • Delete Table 
  • Data Plane (It consists of ‘CRUD’ operation, i.e. Create, Read, Update & Delete)
    • Creating Data
      • PutItem
      • BatchWriteItem
    • Reading Data
      • GetItem
      • BatchGetItem
      • Query
      • Scan
    • Updating Data
      • UpdateItem
    • Deleting Data
      • DeleteItem
      • BatchWriteItem 
  • DynamoDB Stream
    • ListStream
    • DescribeStream
    • GetSharedIterator
    • GetRecords

Tip: Amazon Web Services is the hottest cloud computing infrastructure with a hyper-scale market share of 49 percent. If you want to know which AWS Jobs are trending check out the AWS Developer Salary Guide, get real numbers & choose the right career

Installing DynamoDB on your computer (Local)

You can install a downloadable version of Amazon DynamoDB into your system which is provided in an executable .jar file. The downloaded file can be installed and run on Windows, Linux, MacOS, and the systems that run on Java.

You need to have Java Runtime Environment (JRE) version 6.x or above installed on your system. The application does not run on earlier versions of JRE.

Following steps will allow you to set up and run DynamoDB on your computer system: -

  1. Download DynamoDB for free on AWS Amazon’s official website.
  2. To start DynamoDB on your computer, open a command prompt window, navigate to the directory where you extracted DynamoDBLocal.jar, and enter the following command. java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
  3. If you're using Windows PowerShell, be sure to enclose the parameter name or the entire name and value like this: java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jarDynamoDB processes incoming requests until you stop it. To stop DynamoDB, press Ctrl+C at the command prompt. DynamoDB uses port 8000 by default. If port 8000 is unavailable, this command throws an exception. For a complete list of DynamoDB runtime options, including -port, enter this command. java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -help
  4. Before you can access DynamoDB programmatically or through the AWS Command Line Interface (AWS CLI), you must configure your credentials to enable authorization for your applications. Downloadable DynamoDB requires any credentials to work, as shown in the following example. AWS Access Key ID: "fakeMyKeyId" AWS Secret Access Key: "fakeSecretAccessKey" You can use the aws configure command of the AWS CLI to set up credentials.
  5. You can start writing applications. To access DynamoDB running locally, use the --endpoint-url parameter. For example, use the following command to list DynamoDB tables. aws dynamodb list-tables --endpoint-url http://localhost:8000

Now, if cloud computing fascinates you and you want to make a long-term career around it, more specifically in AWS technology then check out the AWS Career Path and gain a complete insight about this most demanded IT profession. 

Setting up DynamoDB (Web Services)

If you plan to interact with DynamoDB only through the AWS Management Console, you don't need an AWS access key, and you can skip ahead to Using the Console.

To use the Amazon DynamoDB web services, you need to perform the following steps: -

  1. Sign up for AWS.
  2. Get an AWS access key (used to access DynamoDB programmatically).
  3. Configure your credentials (used to access DynamoDB programmatically).

Signing Up for AWS

To use the DynamoDB service, you must have an AWS account. If you don't already have an account, you are prompted to create one when you sign up. You're not charged for any AWS services that you sign up for unless you use them.

To sign up for AWS

  1. Open https://portal.aws.amazon.com/billing/signup.
  2. Follow the online instructions.

Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad.

Getting an AWS Access Key

Before you can access DynamoDB programmatically or through the AWS Command Line Interface (AWS CLI), you must have an AWS access key. You don't need an access key if you plan to use the DynamoDB console only.

Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. If you don't have access keys, you can create them from the AWS Management Console. As a best practice, do not use the AWS account root user access keys for any task where it's not required. Instead, create a new administrator IAM user with access keys for yourself.

The only time that you can view or download the secret access key is when you create the keys. You cannot recover them later. However, you can create new access keys at any time. You must also have permission to perform the required IAM actions.

However, to stay current with the change in the cloud computing environment, students and professionals should follow some of the top AWS thought leaders and influencers. Check out this comprehensive list of industry Best AWS Influencers/Leaders you must follow!

To create access keys for an IAM user

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane, choose Users.
  3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials tab.
  4. In the Access keys section, choose to Create access key.
  5. To view the new access key pair, choose Show. You will not have access to the secret access key again after this dialog box closes. Your credentials will look something like this:
    • Access key ID: AKIAIOSFODNN7EXAMPLE
    • Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  6. To download the key pair, choose Download .csv file. Save the keys in a secure location. You will not have access to the secret access key again after this dialog box closes. Keep the keys confidential in order to protect your AWS account and never email them. Do not share them outside your organization, even if an inquiry appears to come from AWS or Amazon.com.  No one who legitimately represents Amazon will ever ask you for your secret key.
  7. After you download the .csv file, choose Close. When you create an access key, the key pair is active by default, and you can use the pair right away.

Configuring Your Credentials

Before you can access DynamoDB programmatically or through the AWS CLI, you should configure your credentials to enable authorization for your applications.

There are several ways to do this. For example, you can manually create the credentials file to store your access key ID and secret access key. You also can use the AWS configure command of the AWS CLI to create the file automatically. Alternatively, you can use environment variables.Before moving to the next section, let’s quickly go through the Free AWS Quiz to practice what you have learned so far.

Terminologies Associated with DynamoDB 

  • Tables–DynamoDB stores data in tables which is similar to the concept of other databases. A table is a collection of data.
  • Items– Every table contains zero or more items. An item is a group of attributes that is uniquely identifiable among all of the other items. Items in DynamoDB are similar in many ways to rows, records, or tuples in other database systems. In DynamoDB, there is no limit to the number of items you can store in a table.
  • Attributes– Each item is formulated of one or more attributes. An attribute is a fundamental data element, something that does not need to be broken down any further.

The following diagram shows a table named People with some example items and attributes-

Terminologies Associated with DynamoDB 

Note the following about the People table:

  • Each item in the table has a unique identifier, or primary key, that distinguishes the item from all of the others in the table. In the Peopletable, the primary key consists of one attribute (PersonID).
  • Other than the primary key, the Peopletable is schema-less, which means that neither the attributes nor their data types need to be defined beforehand. Each item can have its own distinct attributes.
  • Most of the attributes are scalar, which means that they can have only one value. Strings and numbers are common examples of scalars.
  • Some items have a nested attribute (Address). DynamoDB supports nested attributes up to 32 levels deep.

Note: Comprehensive knowledge of Amazon DynamoDB can make you a superstar in AWS so can knowledge of Amazon Migration. Hence, If you are looking to make your career in AWS and land a high-paying job, consider enrolling in a professional Cloud Migration Course.

Amazon DynamoDB Primary Key

When you create a table, in addition to the table name, you have to specify the primary key of the table. The primary key uniquely identifies each item in the table, so that no two items can have the same key.

DynamoDB supports two different kinds of primary keys:

  • Partition key– A simple primary key that is 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 (physical storage internal to DynamoDB) in which the item will be stored. An important rule to implementing a Partition key is that in A table that has only a partition key, no two items can have the same partition key value. The People table described in Tables, Items, and Attributes is an example of a table with a simple primary key (PersonID). You can access any item in the People table directly by providing the PersonId value for that item.
  • Partition key and sort key– It is referred to as a composite primary key, this type of key is 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 (physical storage internal to DynamoDB) in which the item will be stored. All items with the same partition key value are stored together, in sorted order by sort key value.

Amazon DynamoDB Secondary Indexes

You can create one or more secondary indexes on a table. A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key. DynamoDB doesn't require that you use indexes, but they give your applications more flexibility when querying your data. 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.

DynamoDB supports two kinds of indexes:

  • Global secondary index – An index with a partition key and sort key that can be different from those on the table.
  • Local secondary index – An index that has the same partition key as the table, but a different sort key.

Each table in DynamoDB has a limit of 20 global secondary indexes (default limit) and five local secondary indexes per table.

Also, if you want to enhance your knowledge of AWS. Check out the AWS Step Functions Concepts with Example to gain complete insight o this domain.   Next, we will check through the Amazon DynamoDB Streams.

Amazon DynamoDB Streams

DynamoDB Streams is an optional feature that captures data modification events in DynamoDB tables. The data about these events appear in the stream in near-real-time, and in the order that the events occurred.

Each stream record also contains the name of the table, the event timestamp, and other metadata. Stream records have a lifetime of 24 hours; after that, they are automatically removed from the stream.

You can use DynamoDB Streams together with AWS Lambda to create a trigger—code that executes automatically whenever an event of interest appears in a stream. For example, consider a Customers table that contains customer information for a company. Assume that you want to send a "welcome" email to each new customer. You can allow a stream on that table, and then associate the stream with a Lambda function. The Lambda function will execute whenever a new stream record appears, but only process new items added to the Customers table. For any item that has an EmailAddress attribute, the Lambda function would invoke Amazon Simple Email Service (Amazon SES) to send an email to that address.

Amazon DynamoDB Streams

In the above example, the last customer, Craig Roe, will not receive an email because he doesn't have an Email Address. However, if you are a beginner and want to know how to create your own first amazon ec2 instance and gain in-depth knowledge on What Is AWS Lambda? We recommend you check out these blogs. 

How does DynamoDB work?

A DynamoDB database can be broken down into three theorems:

  1. Tables: A collection of things that you want to store together
  2. Items: An item is just like a row in a normal database
  3. Attributes: A column or field in a normal databaseHow does DynamoDB work?

A DynamoDB table must have a primary key. There are two possible types to choose from:

  1. Partition Key — Single Attribute —which will just be a field in your data source that uniquely represents the row (e.g., an auto-generated, unique product ID).
  2. Partition Key & Sort Key — Composite Key — which will be a combo of two attributes that will uniquely identify the row, and how the data should naturally be sorted (e.g., Unique product ID and purchase date timestamp)

Your DynamoDB partition key must be unique and sparse. As this key is hashed internally and used to distribute that data for storage. This is a similar technique to Redshift and HBase that prevents hot-spotting of data.

If using a composite key, then two items can have the same Partition Key, but the Sort Key must be unique. This will mean all items with the same Partition key will be stored together but sorted in ascending order using the Sort Key.

Tip: AWS is a big domain with multiple career options. Yet, for the maximum impact learning, AWS from scratch is important, check out our complete AWS Training & Certification Guide for a rewarding career ahead.

How to Create a table in DynamoDB

Step 1: Navigate to the DynamoDB section in AWS.  Select “Create Table“.  

How to Create a table in DynamoDB

Step 2: Fill in with the necessary details and click on “Create.“

How to Create a table in DynamoDB

Step 3: You can view your table being created. Click on “Overview” to understand your table, click on “Items” to edit, insert and query on the table. There are many more options you can use to understand your table better.

How to Create a table in DynamoDB

How to Create a table in DynamoDB

Step 1: Navigate to the DynamoDB section in AWS.  Select “Create Table“.  

How to Create a table in DynamoDB

Step 2: Fill in with the necessary details and click on “Create.“

How to Create a table in DynamoDB

Step 3: You can view your table being created. Click on “Overview” to understand your table, click on “Items” to edit, insert and query on the table. There are many more options you can use to understand your table better.

How to Create a table in DynamoDB

How to Insert a table in DynamoDB? 

Step 1: Navigate to “Items” and click on “Create item.“ 

How to Insert a table in DynamoDB? 

Step 2: It will open a JSON file where you can add different items. Click on the “+” symbol and select “Append” and select what type of data you want to enter. 

How to Insert a table in DynamoDB? 

Step 3: This is what it looks like after adding multiple columns to your table. Click on “Save“. 

How to Insert a table in DynamoDB? 

Step 4: Since it is a NoSQL architecture, you can play around with the columns you add to the table. E.g., “Position.“ 

How to Insert a table in DynamoDB? 

Step 5: This is how your table will look like once you have inserted the data. 

How to Insert a table in DynamoDB? 

Further, if you are looking to garner more information, check out our blog on why EC2 in AWS is the Backbone of AWS to gain better insight. 

How to apply Queries on a table in DynamoDB? 

Step 1: Here, you can frame your query and click on “Start Search” to get the desired result.

E.g., I am searching for all the mobile numbers that are greater than or equals to “1234“. 

How to Insert a table in DynamoDB? 

Step 2: Here, I am searching for the record which has EmpId as “ED4“.

How to Insert a table in DynamoDB? 

The above steps will allow you to create, insert, and query a table in DynamoDB. Consider enrolling in an AWS Training Course to get better insights into AWS and other platforms. 

Summary

  • DynamoDB is a fully managed NoSQL database service provided by Amazon
  • A table is a visualized view of data
  • An item is said to be a set of attributes in a table
  • An attribute is a single field that is linked to an item
  • A primary key is a unique differentiation of data items
  • DynamoDB is a database tool which requires API to interact with an application

So, gear up and give a jumpstart to your AWS professional career by enrolling yourself in a comprehensive AWS Certification Course, today!  If you have any questions for us? Feel free to ask or talk to our counselor; we’ll get back to you! Also, don’t forget to join the professional JanBask AWS Community to get professional guidance and the best career advice

fbicons FaceBook twitterTwitter google+Google+ lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

1 day 27 Apr 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

0 day 26 Apr 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

0 day 26 Apr 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

21 days 17 May 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

0 day 26 Apr 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

0 day 26 Apr 2024

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

-1 day 25 Apr 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

0 day 26 Apr 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

8 days 04 May 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

1 day 27 Apr 2024

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

35 days 31 May 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

0 day 26 Apr 2024

Search Posts

Reset

Receive Latest Materials and Offers on AWS Course

Interviews