Overview of Various Options

Understand your options for creating items in tables from the AWS Console.

Items can be created in the following ways:

  1. By using the PutItem API
  2. Creating items from AWS console
  3. By using the BatchWriteItem API

PutItem

This API is the most common way for inserting items into our database. We can use it to create a new item in a given table. We need to, mandatorily, specify the primary key for the item we are inserting. If the primary key matches with any other item present in the table, the old item is replaced with the new item.

Creating items from AWS Console

This is the simplest way of creating an item in DynamoDB. However, it is manual work and does not scale well to inserting millions of items.

For a hands-on experience, try out the “Create Items in a DynamoDB Table” cloud lab at the end of this chapter!

For this, we can just go to the AWS console, where we created the table.

  1. Click on the Tables tab, located inside the left sidebar.
  2. Choose the table we want to create the item in.
  3. Click on the Create Item button. Create Item Button

BatchWriteItem

We can write items in batches with a maximum size of 25. The total size of the request should be less than 16 MB. And the individual items should be sized at a maximum of 400KB.

This process uses the power of parallel processing to speed up the writing process. We can use this API when we have large amounts of data to be transferred to DynamoDB.

We can achieve a similar speed by calling the Put-Item API from multiple threads in our program. But in that case, we will have to take care of the concurrency logic. In my opinion, it is better to let AWS deal with that.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy