DynamoDB application programming using AWS SDKs
following diagram provides a high-level overview of Amazon DynamoDB application programming using the AWS SDKs.
Interfaces
Low-Level Interfaces: methods that closely resemble low-level DynamoDB API requests.
Document Interfaces: allows you to perform data plane operations (create, read, update, delete) on tables and indexes.
Object Persistence Interface: Instead of performing data plane operations, you create objects that represent items in Amazon DynamoDB tables and indexes, and interact only with those objects. This allows you to write object-centric code, rather than database-centric code.
// Document Interfaces also provide methods to easily convert JSON documents to and from native Amazon DynamoDB data types.
Low level APIs
The Amazon DynamoDB low-level API is the protocol-level interface for DynamoDB. At this level, every HTTP(S) request must be correctly formatted and carry a valid digital signature.
The low-level DynamoDB API uses JavaScript Object Notation (JSON) as a wire protocol format.
DynamoDB uses JSON only as a transport protocol, not as a storage format. The AWS SDKs use JSON to send data to DynamoDB, and DynamoDB responds with JSON. DynamoDB does not store data persistently in JSON format.
Data Type Descriptors
The low-level DynamoDB API protocol requires each attribute to be accompanied by a data type descriptor.
- S - String
- N - Number
- B - Binary
- BOOL - Boolean
- NULL - Null
- M - Map
- L - List
- SS - String Set
- NS - Number Set
- BS - Binary Set
Low level APIs 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.
Low level APIs 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.
Low level APIs 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.