What is DynamoDB?
fully managed NoSQL database service that
- no burden of operating and scaling a distributed database
- offers encryption at rest
- provides on-demand backup capability
With Dynamo, user can
- create database tables that can store and retrieve any amount of data and serve any level of request traffic
- scale up or scale down your tables' throughput capacity without downtime or performance degradation.
- use the AWS Management Console to monitor resource utilization and performance metrics
- create on-demand backups and enable point-in-time recovery for your Amazon DynamoDB tables.
- delete expired items from tables automatically
Core Components
- Tables: Similar to other DB systems, Dynamo stores data in tables.
- Items: An item is a group of attributes that is uniquely identifiable among all of other items. Each table contains 0 or more items. (similar to rows in RDBMS)
- Attributes: An attribute is a fundamental data element, something that does not need to be broken down any further. Each item is composed of one or more attributes. (similar to cols in RDBMS)
- Primary key: uniquely identifies each item in a table. Dynamo supports 2 different types of primary keys
- Partition key - A simple primary key, composed of one attribute known as the partition key.
- Partition key and sort key – Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key.
- Secondary Indexes: A secondary index lets you query the data in the table using an alternate key, in addition to queries against the primary key. DynamoDB supports two kinds of indexes
- Global secondary index – An index with a partition key and sort key that can be different from those on the table.
- Local secondary index – An index that has the same partition key as the table, but a different sort key.
- Dynamo DB streams: an optional feature that captures data modification events in DynamoDB tables. he data about these events appear in the stream in near-real time, and in the order that the events occurred. Each event is represented by a stream record. If you enable a stream on a table, DynamoDB Streams writes a stream record whenever one of the following events occurs
- A new item is added to the table: The stream captures an image of the entire item, including all of its attributes.
- An item is updated: The stream captures the "before" and "after" image of any attributes that were modified in the item.
- An item is deleted from the table: The stream captures an image of the entire item before it was deleted.
// DynamoDB uses the partition key's value as input to an
internal hash function. The output from the hash function determines
the partition (physical storage internal to DynamoDB) in which the
item will be stored. All items with the same partition key value are
stored together, in sorted order by sort key value.
// The partition key of an item is also known as its hash attribute. The term hash attribute derives from the use of an internal hash function in DynamoDB that evenly distributes data items across partitions, based on their partition key values.
// The sort key of an item is also known as its range attribute. The term range attribute derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
// The partition key of an item is also known as its hash attribute. The term hash attribute derives from the use of an internal hash function in DynamoDB that evenly distributes data items across partitions, based on their partition key values.
// The sort key of an item is also known as its range attribute. The term range attribute derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.
// Each stream record also contains the name of the table, the event
timestamp, and other metadata. Stream records have a lifetime of 24
hours; after that, they are automatically removed from the
stream.
// You can use DynamoDB Streams together with AWS Lambda to create a trigger—code that runs automatically whenever an event of interest appears in a stream
// You can use DynamoDB Streams together with AWS Lambda to create a trigger—code that runs automatically whenever an event of interest appears in a stream