image
Interacting with DynamoDB
Start course
Difficulty
Intermediate
Duration
3h 3m
Students
1697
Ratings
4.7/5
Description

This course provides detail on the AWS Database services relevant to the AWS Certified Developer - Associate exam. This includes Amazon RDS, Aurora, DynamoDB, MemoryDB for Redis, and ElastiCache.

Want more? Try a lab playground or do a Lab Challenge!

Learning Objectives

  • Obtain a solid understanding of the following Amazon database services: Amazon RDS, Aurora, DynamoDB, MemoryDB for Redis, and ElastiCache
  • Create an Amazon RDS database
  • Create a DynamoDB database
  • Create an ElastiCache cluster
Transcript

So let’s say you have a DynamoDB table - how do you then interact with it? There are four main ways you can interact with DynamoDB. 

  1. You can use the AWS console, which provides a graphical interface for managing your DynamoDB tables. With the console, you can look at the data in your tables, and add and modify your data. 

  2. You can also use the AWS Command Line Interface or CLI in order to script API calls from a terminal window.

  3. You can write code which interacts with DynamoDB programmatically using the AWS Software Development Kits or SDKs. These SDKs are available for most of the major languages, such as Java, .NET, PHP, Python, Ruby, Go, C++.

  4. Last, you can use the NoSQL Workbench for DynamoDB, which provides a visual IDE tool where you can create, manage, and query your DynamoDB tables. 

You can use any of these methods to access the DynamoDB application programming interface or API. The DynamoDB API is organized as a set of operations that you can execute on your DynamoDB tables.

Each operation has a name, a set of parameters that are required for the command to be complete, and a set of outputs that are sent back in response. 

For example, take the CreateTable API call. As the name suggests, this API call creates a DynamoDB table. However, to run this command successfully, you have to specify certain parameters, such as the table name and how many RCUs and WCUs you’d like to provision for that table. If you form the command correctly, you get an output sent back in response acknowledging that the operation was successful. 

In this lecture, we’ll be talking about the three main categories of operations using the DynamoDB API. 

The first set of operations are called control plane operations. These operations let you manage the DynamoDB tables in your account. So, if you want to list out the tables you have in your account, you could use the ListTables API call. If you want information about a particular table, you can use the DescribeTable API Call. And if you want to modify or make changes to your tables, you can use the CreateTable, UpdateTable, and DeleteTable API calls. 

Then you have the next category of operations, which are data plane operations. These enable you to perform create, read, update, and delete (or CRUD operations) on your DynamoDB tables. For example, if you want to read data from your DynamoDB table, you have six operations you can use: 

  1. You can use the GetItem API call to read a single item. To make this call, you have to specify the exact primary key of the item you’re looking for, meaning you need to specify the partition key, and the sort key if it’s used. This call will return either 0 or 1 items, depending on if the item exists or not. 

  2. Then you have the BatchGetItem API call. This is the same thing as doing multiple GetItem API calls to read items. The only difference is the results are batched, which makes the call more efficient than doing several GetItem API calls. This can return up to 100 values. 

  3. The next option is a Query. With a query, you only have to specify the partition key, and you can optionally choose to add a sort key condition. You can also use filter expressions, which means you can request data and DynamoDB will filter through the response before returning it to you as a single result to give you the data that matches what you’re looking for. 

  4. Then you have a scan. With a scan, you don’t have to specify any keys. You are reading the entire table. Technically, with scans you can have filters too - however, it will still scan the whole table to see if the item matches the filter expression or not. This is the most expensive call out of all of them. 

  5. Finally, you can also use PartiQL to perform gets on your data, by using the API calls ExecuteStatement and BatchExecuteStatement. 

For modifying data, you use the PutItem API call to store a single new record, the UpdateItem API call to modify, and the DeleteItem API call to delete a single record. If you need to make many writes at once, you can use the BatchWriteItem API call. You can also use PartiQL to perform these operations, by using the same API Calls you use to read, ExecuteStatement, and BatchExecuteStatement. 

Finally, you have Transactions operations. For ACID compliance, you can use the built-in API calls to read and write called TransactGetItems and TransactWriteItems, respectively. Or you can use PartiQL by using the API call ExecuteTransaction.  

While I hit most of the major DynamoDB API calls in this lecture, I did not hit all of them. If you’d like more information for any of these DynamoDB operations or you’d like to see all the DynamoDB operations, you can find all the details you need in the AWS API reference. That’s it for this one - see you next time! 

About the Author
Students
237782
Labs
1
Courses
232
Learning Paths
187

Stuart has been working within the IT industry for two decades covering a huge range of topic areas and technologies, from data center and network infrastructure design, to cloud architecture and implementation.

To date, Stuart has created 150+ courses relating to Cloud reaching over 180,000 students, mostly within the AWS category and with a heavy focus on security and compliance.

Stuart is a member of the AWS Community Builders Program for his contributions towards AWS.

He is AWS certified and accredited in addition to being a published author covering topics across the AWS landscape.

In January 2016 Stuart was awarded ‘Expert of the Year Award 2015’ from Experts Exchange for his knowledge share within cloud services to the community.

Stuart enjoys writing about cloud technologies and you will find many of his articles within our blog pages.