AWS Certification : How to use DynamoDB?

Are you preparing for AWS Certified Developer Associate certification exam? In this space, we are writing series of articles on topics which are covered in the developer associate certification exam. You can subscribe to us for receiving the further updates on this topic.

Dynamodb

Developer Associate certification exam is the most easiest exam in the associate level, it is good idea to start your certification from this exam. Also we would recommend you to pass the solutions architect certification exam which covers the concepts of all the services offered in AWS.

Developer Associate Syllabus

Here is the snapshot of blueprint for developer associate is covered in the developer associate exam.

Blueprint for AWS Certified developer associate exam

In this articles we are going to explain about the topic that addresses the Designing and Development as highlighted in the AWS Blueprint for the exam guide.

What is AWS DynamoDB?

The AWS DynamoDB is the fully managed NoSQL database offering from Amazon. This is excellent for organizations that do not want to manage their NoSQL databases. DynamoDB provides faster performance and improved scalability. The biggest advantage is that organizations don’t need to worry about provisioning the database or maintaining it in terms of patching or scaling.

A very important concept for the exam is the throughput provisioning for the database which is the read and write capacity that needs to be place for the database. This is what gets charged to the user when they use aws DynamoDB. Before we delve into throughout provisioning, let’s see how we can go about getting a DynamoDB in place.

How to Set up DynamoDB?

Let’s go through the following steps for creating a DynamoDB database.

Step 1:Log into your AWS Console. You will see the DynamoDB section under the database section.

How to setup Dynamo DB?

Step 2: If you have never provisioned a DynamoDB table before you need to click on the ‘Create table’ option in the next screen.

Create table screen in DynamoDB?

 

Step 3: When creating the DynamoDB table, you will need to provide a table name and the primary key of the table. In our case, we are creating a table with the name of Demo and giving the primary key as ID.

Create Primarykey in DynamoDB

 

When you scroll down the screen and uncheck the ‘Use default settings’ option, you will then see the option of Read capacity and write capacity units. You will also see the estimated cost per month. Leave the settings as it is. You can then click on the Create table at the bottom of the screen.

Once done you will actually then be able to see the Demo table.

DynamoDB Table

 

DynamoDB Table Settings

 

Read and Write Capacity

So provisioned throughput is based on the read and write capacity that is put for the table. So now let’s understand the capacity in more detail.

  • Read Capacity – This is the number of items, 4KB in size that can be read in one second from the table. So let’s say for example you have items which are 20KB in size that need to be read per second from the table. Then to calculate the read capacity, you need to divide the anticipated reads per second by 4KB. So in our case, we need to divide 20Kb by 4Kb and we get 5. So we need to provision 5 read capacity units for our table. We then need to go a step further because there are 2 types of read capacity. One is eventual consistency and the other is strongly consistent read.
    • Eventual consistency is where aws tells that when data is read after a write, it may not reflect the exact data. Yes over a brief period of time, it eventual become consistent and a read would reflect the correct data.
    • Eventual consistency is where aws tells that when data is read after a write it will always give you the most up to date data.

So now the following things need to be considered further for read capacity. Strong consistent reads are more expensive than eventual consistent reads. The default model for read capacity is eventual consistency. The next point to note is that one strongly consistent read is equal to 2 eventual consist reads.

So in our above case, we would get a value of 5 eventual consistent reads. But if we wanted strongly consistent reads then we would need to multiply the read capacity by 2, which would give the right read capacity for our table and that would be 10.

  • Write Capacity – This is the number of items, 1KB in size that can be written in one second to the table. So let’s say for example you have items which are 20KB in size that need to be written per second to the table. Then to calculate the write capacity, you need to divide the anticipated writes per second by 1KB. So in our case, we need to divide 20Kb by 1Kb and we get 20. So we need to provision 20 writes capacity units for our table.

Local and Global Secondary Indexes

The next important concept in DynamoDB is local and secondary indexes. DynamoDB allows you to define indexes based on the columns of the table which make it easier to query the data.

Let’s take the example that we have the following items in our DynamoDB table.

aws-dynamodb-table-indexes

To create an index we can go to the Indexes section in the DynamoDB table

DynamoDB Index List Section

  • Click on the Create Index to create a new index for the table. Note that this will create a new global secondary index.
  • We can now define another column in the table to become our primary key for the index.
  • Also note that there is an additional read and write capacity for indexes.

How to create index in DynamoDb table?

The project attributes tells what parts of the table need to be part of the Index. You have the following options:

  1. All attributes – So all attributes from the table will be copied to the index.
  2. Keys – Here the keys from the table are copied to the index.
  3. Include – Here you can decide which attributes from the table should be part of the index.

A Local secondary index can use the same read write capacity of the main table. But these indexes can only be created at table creation time.

Also for a local secondary index, the primary key needs to be same as the primary partition key of the main table.

Important Points to Remember for Developer Associate Certification 

  1. DynamoDB is the fully managed NoSQL offering from AWS.
  2. There is a charge for the read and write capacity for the DynamoDB table.
  3. To calculate read capacity we need to take the size of the anticipated reads to the nearest 4KB.
  4. Strong consistent reads are more expensive than eventual consistent reads.
  5. The default model for read capacity is eventual consistency.
  6. One strongly consistent read is equal to 2 eventual consist reads.
  7. To calculate write capacity we need to take the size of the anticipated writes to the nearest 1KB.
  8. A Local secondary index can use the same read write capacity of the main table
  9. The local secondary index can only be created at table creation time
  10. Also for a local secondary index, the primary key needs to be same as the primary partition key of the main table.
  11. For the global secondary index, the index primary can be different from the primary partition key of the main table.

Summary

In this article we have explained about how to create and configure the DynamoDB, how to create indexes and important points regarding the DynamoDB that needs to be remembered for the exam. DynamoDB is the fully functional NoSQL database from AWS. You are no longer required to use either MongoDB or other NoSQL databases if you are using the DynamoDB.

If you are preparing for the AWS certifications exam and looking for any help, please send us a mail to call to our customer support team. 

 

 

 

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

2 thoughts on “AWS Certification : How to use DynamoDB?”

  1. So in our above case, we would get a value of 5 eventual consistent reads. –

    As per the calculation made above the 20KB per second means 5 Strong-consitent reads or 10 eventual consistent reads.

    Isnt that so?

  2. “Eventual consistency” is where aws tells that when data is read after a write it will always give you the most up to date data.

    should be

    “Strong consistency” is where aws tells that when data is read after a write it will always give you the most up to date data.

Leave a Comment

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


Scroll to Top