DynamoDB - Creating Items
Last Updated :
13 Feb, 2024
Creating an item in a DynamoDB table is a vital operation in application development that allows you to upload data. We will explore how we can create items for tables using different methods used for different purposes.
Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. With DynamoDB, you can create database tables that can store and retrieve any amount of data and serve any level of request traffic. You can scale up or scale down your table throughput capacity without downtime or performance degradation. To know more about it read this article.
Components Of DynamoDB
- AWS Account: Before starting this tutorial, you must have an AWS account. Read this article in case you don't have an AWS account.
- DynamoDB Table: You must have a table, so you can create/write an item into it. If you don't know how to create the table read this article.
Data Model in DynamoDB
- Tables: Similar to any other database system, DynamoDB stores data in tables. A table is a collection of items.
- Items: An item is a group of attributes that is uniquely identifiable among all of the other items. Each table contains zero or more items.
- Attributes: Each item is composed of one or more attributes. An attribute is a fundamental data element, something that does not need to be broken down any further.
For example, consider table 'People'.It has 3 items in it. Each item has 3 attributes namely, FirstName, LastName, and Age. For a more detailed overview of the table read this article.
Primary Key: The primary key uniquely identifies each item in the table, so that no two or more items can have the same key.
Types Of Keys in DynamoDB
- Partition key - A simple primary key, composed of one attribute known as the partition key. It uses the partition key's value as input to an internal hash function.
- Partition key and Sort key - It is 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.
For a more detailed overview about key read this article.
Step-By-Step Guide To Create Items In AWS
Step 1: Login into AWS -> https://aws.amazon.com/ Management
Step 2: After signing in you will land on the AWS Management Console page and search for Dynamo as shown below.

Read an item using the Amazon Management Console (GUI)
Step 1: After landing on the DynamboDB dashboard, go to Tables from the sidebar and click on your table name (in my case 'Music').

Step 2: From the Top right go to Explore table items. This will allow you to perform CRUD operations on table.

Step 3: Select Create item, from this you will be able to create an item for the table.

Step 4: Add data in your respective fields. We can also add additional attributes in table by clicking on Add new attribute and then selecting datatype of your data.

Step 5: After filling all the fields Create item.

Step 6: After refreshing exploring items page you can see you create item at the bottom.

Read an item using the Amazon CLI (Command Line Interface)
Step 1: Select Cloudshell from the bottom left or just open AWS CLI on your system.
Syntax:
aws dynamodb put-item --table-name TABLE-NAME --item '{"ATTRIBUTE" : {"DATATYPE":"DATA"}}'
TABLE-NAME: add your table name
ATTRIBUTE: add your attribute name
DATATYPE: In CLI there are different datatype descriptors for each datatype.
- S – String
- N – Number
- B – Binary
- BOOL – Boolean
- NULL – Null
- M – Map
- L – List
- SS – String Set
- NS – Number Set
- BS – Binary Set
For Example:
aws dynamodb put-item --table-name Music --item '{"Artist" : {"S":"Bring be the horizon"}, "Title" : {"S":"Strangers"}, "Year" : {"N":"2022"}}'
Note: You can add any number of attributes for each item.

Step 2: Check if successfully created or not. Goto explore items page and check at the bottom.

Best Practices for Creating Items
- Primary Key Design: Select Partion key or Composite according to your data you are going to insert. In above example we selected composite key because Artists name can be repeated but both artist name and song can't be similar.
- Large Items and Attributes: DynamoDB currently limits the size of each item (400 KB) that is stored in a table, which includes both attribute names and values binary length.
- Timestamps: While using timestamp as one of your attributes it is good to use ISO time format (YYYY-MM-DD'T'hh:mm:ss'Z').
Conclusion
We have successfully created an item into the DynamoDB table (Music) using two methods Amazon Management Console and CloudShell (AWS CLI). Using GUI you can easily create items by just filling fields but if you want to create an item from outside Amazon Management Console we can use AWS CLI.
Similar Reads
AWS DynamoDB - Creating a Table
DynamoDB allows users to create databases capable of storing and retrieving any amount of data and comes in handy while serving any amount of traffic. It dynamically manages each customerâs request and provides high performance by automatically distributing data and traffic over servers. It is a ful
2 min read
DynamoDB - Create Table
Tables are the backbone of any Relational Database Management System. Tables are used to store data in an organized form so operation on the data and retrieval of data becomes seamless. The AWS DynamoDB provides both RDBMS and Non-relational databases. This article mainly focuses on the relational p
2 min read
DynamoDB - Data Types
DynamoDB supports many different data types for attributes within a table. They can be categorized as follows: Scalar Types â A scalar type can represent exactly one value. The scalar types are number, string, binary, Boolean, and null.Document Types â A document type can represent a complex structu
6 min read
DynamoDB - Aggregation
In today's data-driven world, the ability to intelligently transform big data into actionable insights is crucial for the success of business. DynamoDB, offered by Amazon, act as a versatile and scalable NoSQL database solution known for its flexibility and performance levels. Aggregation plays a fu
7 min read
Creating AWS DynamoDB Table Using Terraform
I'm going to show how to use Terraform to create a DynamoDB table in AWS. Terraform lets you define infrastructure like databases as code. This makes it easy to version control and share with others. In this article, I'll walk through the steps to set up a Terraform file and define a DynamoDB table
15+ min read
Delete Table In DynamoDB
DynamoDB allows users to create databases capable of storing and retrieving any amount of data and comes in handy while serving any amount of traffic. It dynamically manages each customerâs request and provides high performance by automatically distributing data and traffic over servers. It is a ful
4 min read
Creating a NoSQL Table Using Amazon DynamoDB
Pre-requisite: DynamoDB Amazon DynamoDB is a fully managed NoSQL database provided by amazon that supports both document and key-value stored data. In this article, we will learn how to create a table, add data, scan, a query that table, and delete the data by using the DynamoDB console. Benefits of
2 min read
DynamoDB - Tables, Items, and Attributes
In DynamoDB the Tables, Items, and Attributes are among the core components, and we will be discussing them in detail in this article. Tables A table in DynamoDB is a collection of items. The key factors that make it unique are listed below: Dynamodb stores data in a table which is nothing but a col
2 min read
DynamoDB - Using the Console
The AWS management console for Amazon DynamoDB can be accessed from here. The AWS management console can be used for the following: Perform Table operations like create, update and delete a table from the database.To get additional storage and processing capability.To keep track of all the relevant
4 min read
DynamoDB - Read Consistency
Amazon DynamoDB is available in multiple AWS Regions around the world. Each Region is independent and isolated from other AWS Regions. For example, if you have a table called People in the us-east-2 Region and another table named People in the us-west-2 Region, these are considered two entirely sepa
2 min read