DynamoDB - Basic Concepts

Before using DynamoDB, you should be familiar with its core components and ecosystem. In the DynamoDB ecosystem, you work with tables, attributes, and elements. A table contains sets of elements, and elements contain sets of attributes. An attribute is a fundamental element of data that does not require further decomposition, i.e., a field.
Primary key
Primary keys serve as a means of uniquely identifying the elements of a table, while secondary indexes provide query flexibility. DynamoDB writes events in a stream by changing table data.
Creating a table requires not only specifying a name, but also a primary key; which identifies the elements of the table. No two items share a key. DynamoDB uses two types of primary keys −
-
Partition key − This simple primary key consists of a single attribute called "partition key". Internally, DynamoDB uses the key value as input to a hash function to determine the store.
-
Partition Key and Sort Key - Known as a "composite primary key", this key consists of two attributes.
-
Partition key and
-
Sort key.
DynamoDB applies the first attribute to the hash function and stores the elements with the same partition key; with their order determined by the sort key. Elements can share section keys, but not sort keys.
-
Partition key − This simple primary key consists of a single attribute called "partition key". Internally, DynamoDB uses the key value as input to a hash function to determine the store.
Partition Key and Sort Key - Known as a "composite primary key", this key consists of two attributes.
Partition key and
Sort key.
DynamoDB applies the first attribute to the hash function and stores the elements with the same partition key; with their order determined by the sort key. Elements can share section keys, but not sort keys.
Primary key attributes only allow scalar (single) values; and string, numeric, or binary data types. Non-key attributes do not have these restrictions.
Secondary indices
These indexes allow you to query table data using an alternate key. While DynamoDB doesn't force you to use them, they do optimize queries.
DynamoDB uses two types of secondary indexes −
-
Global secondary index - This index has partitioning and sorting keys, which can be different from the table keys.
-
Local secondary index - This index has an identical partition key to the table, however its sort key is different.
Global secondary index - This index has partitioning and sorting keys, which can be different from the table keys.
Local secondary index - This index has an identical partition key to the table, however its sort key is different.
API
API operations offered by DynamoDB include control plane operations, data plane operations (such as create, read, update, and delete), and streams. In control plane operations, you create and manage tables using the following tools:
- CreateTable
- DescribeTable
- ListTables
- update table
- DeleteTable
In the data plane, you perform CRUD operations with the following tools:
Create | To read | Refresh | delete |
---|---|---|---|
PutItem BatchWriteItem |
GetItem BatchGetItem inquiry scanning |
UpdateItem |
Delete item BatchWriteItem |
PutItem
BatchWriteItem
GetItem
BatchGetItem
inquiry
scanning
Delete item
BatchWriteItem
Stream operations manage the stream table. You can view the following flow tools −
- ListStreams
- DescribeStream
- GetShardIterator
- GetRecords
Granted Bandwidth
When you create a table, you specify a provisioned throughput that reserves resources for reading and writing. You use power units to measure and set bandwidth.
When applications exceed the set bandwidth, requests are not fulfilled. The DynamoDB GUI console allows you to monitor installed and used bandwidth for better and dynamic provisioning.
Reading Sequence
DynamoDB uses ultimately consistent and strongly consistent reads to support the needs of dynamic applications. Ultimately, consistent reads do not always deliver current data.
Strongly consistent reads always deliver current data (except for hardware failure or network problems). Ultimately, consistent reads serve as the default setting, which requires a value of true in the ConsistentRead parameter to change .
Partitions
DynamoDB uses partitions to store data. These table memory allocations are SSD-enabled and are automatically replicated across zones. DynamoDB manages all partition tasks without requiring user intervention.
When a table is created, the table enters the CREATING state, in which partitions are allocated. When it reaches the ACTIVE state, you can perform operations. The system changes partitions when its capacity reaches its maximum or when you change bandwidth.