In this article, we will work on DynamoDB tables. DynamoDB is a NoSQL database that stores document data or key-value pairs. A Dynamodb table consists of items and each item is made up of attributes. Different items can have different attributes. See the below example:
Example 1: { "MovieID": 123, "Name": "Godfather", "Rating": 9.1, "Year": 1972 } Example 2: { "Director": "Quentin Tarantino", "MovieID": 200, "Name": "Pulp Fiction", "Year": 1994 }
Each table has a partition key which acts as a primary key in items. The following operations will be performed in this article:
- Create a Table
- Describe a Table
- Update a Table
- Delete a Table
- List tables in DynamoDB
Creation of DynamoDB Table:
Login to your amazon console and open DynamoDB. Click on Create table button. Provide table name say, geeksforgeeks, and primary key as UserID. Leave the rest of the settings as default and click on Create. See the below image:
We see that table has been created.
Describe a Table:
To get details of the table, click on the table name. In the Overview tab of the table, go to the table details section. There you can find the details of the table. See the below image:
Update a Table:
There are many operations that can be performed under updation. The operations are as below:
- Modify table’s throughput provisioned settings.
- Change table’s read or write capacity mode.
- Manipulate global secondary indexes on the table.
- Enable or disable DynamoDB Streams on the table
We will change the table’s read or write capacity mode. There are two modes, first, provisioned, second, on-demand. By default, for the free tier, it will be set to provisioned. In the above image, Table Details, we can see that Read/Write capacity mode is set to provisioned. To update the table, it will be changed to On-Demand. See the below image:
We see that the Read/write capacity mode is set to On-Demand. Thus, the table got updated.
Delete a Table:
To delete a table, navigate to the tables tab, select table, and click on Delete Table. A prompt will appear, with two options:
- Delete all the CloudWatch alarms for this table
- Create a backup before deleting this table.
In this example, the first option is selected and the second is not. To confirm deletion type delete and click the Delete button.
List Tables:
To get the list of all the tables in DynamoDB, click on the tables tab in DynamoDB. It will list all the tables created in Dynamodb. See the below image:
We see that two tables are present in DynamoDB.
No comments:
Post a Comment