DynamoDB – API Interface
DynamoDB offers a wide set of powerful API tools for table manipulation, data reads, and data modification.
Amazon recommends using AWS SDKs (e.g., the Java SDK) rather than calling low-level APIs. The libraries make interacting with low-level APIs directly unnecessary. The libraries simplify common tasks such as authentication, serialization, and connections.
Manipulate Tables
DynamoDB offers five low-level actions for Table Management −
-
CreateTable − This spawns a table and includes throughput set by the user. It requires you to set a primary key, whether composite or simple. It also allows one or multiple secondary indexes.
-
ListTables − This provides a list of all tables in the current AWS user”s account and tied to their endpoint.
-
UpdateTable − This alters throughput, and global secondary index throughput.
-
DescribeTable − This provides table metadata; for example, state, size, and indices.
-
DeleteTable − This simply erases the table and its indices.
Read Data
DynamoDB offers four low-level actions for data reading −
-
GetItem − It accepts a primary key and returns attributes of the associated item. It permits changes to its default eventually consistent read setting.
-
BatchGetItem − It executes several GetItem requests on multiple items through primary keys, with the option of one or multiple tables. Its returns no more than 100 items and must remain under 16MB. It permits eventually consistent and strongly consistent reads.
-
Scan − It reads all the table items and produces an eventually consistent result set. You can filter results through conditions. It avoids the use of an index and scans the entire table, so do not use it for queries requiring predictability.
-
Query − It returns a single or multiple table items or secondary index items. It uses a specified value for the partition key, and permits the use of comparison operators to narrow scope. It includes support for both types of consistency, and each response obeys a 1MB limit in size.
Modify Data
DynamoDB offers four low-level actions for data modification −
-
PutItem − This spawns a new item or replaces existing items. On discovery of identical primary keys, by default, it replaces the item. Conditional operators allow you to work around the default, and only replace items under certain conditions.
-
BatchWriteItem − This executes both multiple PutItem and DeleteItem requests, and over several tables. If one request fails, it does not impact the entire operation. Its cap sits at 25 items, and 16MB in size.
-
UpdateItem − It changes the existing item attributes, and permits the use of conditional operators to execute updates only under certain conditions.
-
DeleteItem − It uses the primary key to erase an item, and also allows the use of conditional operators to specify the conditions for deletion.