![]() |
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
Data Model in DynamoDB
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
For a more detailed overview about key read this article. Step-By-Step Guide To Create Items In AWSStep 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.
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
ConclusionWe 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. Creating Items In DynamoDB – FAQ’s1. What are items in DynamoDB?
2. What is the maximum size of an item in DynamoDB?
3. Can we increase item size in DynamoDB?
|
Reffered: https://www.geeksforgeeks.org
Amazon Web Services |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |