---
# System prepended metadata

title: Dynamo DB Day II

---

# Dynamo DB Day II

---

* it is a NoSQL db
* It is use having data in real time
    * Every row is an item and can support different schema
* It does require to set primary key 

## To Create table 
* Provide table name and primary key
    * Primary key: can be a combination of partion key + sort key

### Number of partitions is decided by 2 factors
* Primary key = partition key + sort key 
* As the table gets bigger DynamoDB 
* it writes 2 copies asyncronsly to make sure of data consistancy RCU (strong consistant read) WCU (strong consistant write)
* Data is physically sort when inserted.
* The 3rd copy is behind few milisecs
* Provides very predictable performace
* In order to not to loose DB writes due to getting 500 error
    * build the system with autoscaling
    * increase RCU and WCU 
    * decrease can only be done once in a hour

![DynamoDB table creation](https://i.imgur.com/45Fvppw.png)

* DynamoDB stores data in partitions and divides a table's items into multiple partitions based on the partition key value

### Data Replicaiton

![](https://i.imgur.com/pXTnfhy.png)


* A replica table (or replica, for short) is a single DynamoDB table that functions as a part of a global table. Each replica stores the same set of data items. Any given global table can only have one replica table per region, and every replica has the same table name and the same primary key schema.


* on put items execute a lambda function
* Effectivly it is same as creating a store procedure