05
FebCELEBRATING 72nd REPUBLIC
30% OFF from 20th to 31st Jan REPUB30
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.
Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. It lets you offload the administrative level burden of operating and scaling a distributed database so that you don’t have to worry about hardware provisioning, setup, and configuration, replication, software patching, or cluster scaling. Amazon DynamoDB offers encryption at rest, which eliminates the operational burden and complexity involved in the protection of sensitive information.
With the help of Amazon DynamoDB, we can easily create database tables that can store and retrieve any quantity of data and serve traffic request of any level. You may also scale up and scale down your table throughput capacity without any downtime or degradation of performance. With the use of the AWS management console, you can easily monitor the utilization of resource and performance results.
Amazon DynamoDB has great benefits. One of the top benefits is you can easily take backup and restore your database on-demand without even degrading the performance or availability of your applications. It makes use of a new and unique distributed technology that allows you to complete backups in seconds only depending upon the table size. You can take backups that are consistent within seconds across thousands of partitions without worrying about long-running backups processes or schedules. All backups are systemized, easily searchable, and retained until explicitly deleted.
You can access Amazon DynamoDB by using three different methods: -
DynamoAPI offers a wide set of actions which 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 |
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: -
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: -
DynamoDBLocal.jar
, and enter the following command. java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
java -D"java.library.path=./DynamoDBLocal_lib" -jar DynamoDBLocal.jar
DynamoDB 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
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.aws dynamodb list-tables --endpoint-url http://localhost:8000
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: -
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.
Read: How to Create Amazon Chatbot & Integrate with Facebook?
Part of the sign-up procedure involves receiving a phone call and entering a verification code on the phone keypad.
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 permissions to perform the required IAM actions.
AKIAIOSFODNN7EXAMPLE
wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
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.
The following diagram shows a table named People with some example items and attributes-
Note the following about the People table:
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:
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:
Each table in DynamoDB has a limit of 20 global secondary indexes (default limit) and five local secondary indexes per table.
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.
Read: How To Use Amazon EKS And Deploy A Kubernetes Application With It?
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.
In the above example, the last customer, Craig Roe, will not receive an email because he doesn't have an Email Address.
A DynamoDB database can be broken down into three theorems:
A DynamoDB table must have a primary key. There are two possible types to choose from:
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.
Step 1: Navigate to the DynamoDB section in AWS. Select “Create Table“.
Step 2: Fill in with the necessary details and click on “Create.“
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.
Step 1: Navigate to “Items” and click on “Create item.“
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.
Read: Amazon Redshift vs Amazon RDS vs DynamoDB vs SimpleDB
Step 3: This is what it looks like after adding multiple columns to your table. Click on “Save“.
Step 4: Since it is a NoSQL architecture, you can play around with the columns you add to the table. E.g., “Position.“
Step 5: This is how your table will look like once you have inserted the data.
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“.
Step 2: Here, I am searching for the record which has EmpId as “ED4“.
The above steps will allow you to create, insert, and querying a table in DynamoDB.
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.
AWS
DevOps
Data Science
Hadoop
Salesforce
QA
Business Analyst
MS SQL Server
Python
Artificial Intelligence
Machine Learning
Tableau
Search Posts
Trending Posts
Top 30 Core Java Interview Questions and Answers for Fresher, Experienced Developer
34.2k
Cloud Computing Interview Questions And Answers
28.6k
What is SFDC? What does SFDC stand for?
28.6k
Difference Between AngularJs vs. Angular 2 vs. Angular 4 vs. Angular 5 vs. Angular 6
24.5k
SSIS Interview Questions & Answers for Fresher, Experienced
20.8k
Related Posts
Receive Latest Materials and Offers on AWS Course
Interviews