# DynamoDB

## DynamoDB

{% embed url="<https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html>" %}

* AWS's Serverless, **NoSQL** fully managed database.
  * Provides zero downtime maintenance and it has no versions (major, minor, or patch).
  * As NoSQL it does not support `JOIN` operations.
  * It is recommended to denormalize your data models to reduce round trips and processing power to queries.
  * But it still provides `read consistency` and `ACID transactions`.
* It's purpose for operational workloads that require consistent performance at any scale.
  * Ex.: It delivers single-digit milisecond performance for a shopping cart use case, whether you have 10 or 100 million users.
* Uses `IAM` to help you securely control access to your DynamoDB resources.
  * Because of this, there are no usernames or passwords for accessing it.
* **By default DynamoDB encrypts all custumer data at rest.**
* **By default, DynamoDB automatically replicates your data across three AZs.**
* **Continuous backups** provide you per-second granularity to recovery.
  * You can restore a table to any point in time up to the second during the last 35 days.
  * And these backups and restores don't use provisioned capacity.
  * And put no impact on the performance or availability of your applications.

## **Global Tables**

DynamoDB global tables enable a 99.999% availability and multi-Region resilience.

## Capacity Modes

### **Provisioned**

* You specify the number of reads and writes per second that you expect your application to require.
* You can use autoscaling can adjust provisioned capacity based on demand.
* Use cases:
  * Predictable traffic.
  * Traffic is consistent or ramps gradually.

### **On-Demand**

* Pay-as-you-go pricing for read and write requests.
* Instantly scales up or down your tables to adjust for capacity. *(Zero capacity planning)*
* Also scales down to zero so you don't pay for throughput when your table doesn't have traffic.
* No cold starts.
* Use cases:
  * Unpredictable traffic.
  * Traffic hard to forecast.

## Usual Table Example

* Tables: *ex.: Person.*
* Attributes: *ex.: FirstName, LastName, Email, ...*
* Items: *ex.: Persons table contains items of individual people.*
* **Partition Keys** and optional **Sort Key** defined for fast access to items.

## Basic Price Models

* DynamoDB charges for reading, writing and storing data in your tables, along with any optional features you choose to enable.
* Price also depends on the capacity mode:
  * `on-demand`: Pay only for what you use.
  * `provisioned`: You will be charged for the throughput capacity event if not fully utilized.
* It offers a free tier that provides 25GB of storage, and can handle 200 Million requests per month.
