Saturday, June 21, 2025

Dynamo db

Dynamo db

Class 51th AWS Dynamo db 21th

What is nosql database?

  • Nosql databases are a category of database management system that differ from traditional relational  database(SQL) in several key ways.
  • They are designed to handle large volumes of unstructured, semi-structured, or structured data with high performance, scalability, and flexibility.
Key Characteristics of No sql database

Schema Flexibility

Unlike relational databases, which require a predefined schema, Nosql databases allow for dynamic and flexible schema

Horizontal scalability

Nosql databases are designed to scale out distributing data across multiple servers or node,this contrasts with vertical scaling in relational databases,which often involves adding more resources to a single server.

High performance

They are optimized for high read and write performance, often at the expenses of strong consistency. This makes hem suitable for applications requiring low-latency data access.

Types of NoSQL database

Key-value stores

Eample :Redis,dynamoDB

Description:Data is toed as key-value pairs ,These databases are highly performance and are used for caching session management, and real-time data processing

Document store

Example:MongoDB,CouchDB

Description:data is stored in documents(usually Json or Bson),Document stores are flexible and can handle complex, hierarchical data structure, making them suitable for  content management and web applications

Column-family stores

Example:Apache Cassandra,Hbase

Description :Data is stored in columns rather than rows, and column are grouped into families.These database are optimized for read and write performance and are user in applications requiring high throughput and large scale data processing.

Graph database

Example:Neo4j,Amazon Neptune

Desciption:Data is represented as nodes,edges,and properties,graph databases are ideal for applications involving complex relationships and connections,such as social networks,recommendation engines and fraud detection

What is dynamoDB?

Amazon dynamoDB  is  a fully managed Nosql database service provided by  Amazon webservice(AWS)that delivered high performance, scalability and reliability

It is designed to handle large amounts of data with eash and allows developers to offload the administrative burden of operating and scaling a distributed database.

It is a serverless and public database service(database-as-a-service –Dbaas)key/value & document model.

Data stores in tables rows format.we call the rows as items.there is no affixed structure(schema) to the table

Partition key column must be unique. We can also add a sort key(optional) to organize the data more effectively.

AWS takes care of all the basic need like maintenance.Highly resilient across Azs,optinally global availability.

Backups,PITR,encryption at rest.Event-driven integration(on  database record changes)

DynamoDB table

DynamoDB table is a collection of items(in RDS we call rows)

No fiex structure required to maintain (expect partition and sort key columns)

Table can contain only simple key (partition) or composite key(partition+Sort)-primary key

Each item max size is 400 KB

No fixed structure required to maintain (expect partition and sort key columns)

Capacity unite(CUs) are the measurement for the DB performance.

To write the data write capacity units(WCU),1 WCU – 1 Kb per sec.

To read the data –read capacity units(RCU),1 RCU -4 kb per sec


Practical

Step1: Create one table emp,empno is partition key is the unique column 

Choose Provisioned 

Don't do any change click create table 
Tables created

Step2: to insert the records Select the the table action explore item,

Click create item, empno is partition key remaining attributes are non unique columns, click create item

Step3:Records are inserted successfully

Step4: See allow the records, with proper order  

here only we use the query safe performance issue, Scan take more performance issue if big table 

Step5: Query ,filter the record empno 1 

Step6: Scan filter


Step7: Creating one more table dept with sort key this composite key 

Secondary index 

Don't do any changes click create table 
Step8: create item enter the value click create item


Step9: i have deptno.json 20 records in local directory ,plan to upload CLI 
C:\Users\Administrator\Desktop\SofwareEngineering_E0>aws configure
AWS Access Key ID [****************IEW6]:
AWS Secret Access Key [****************xeEr]:
Default region name [eu-west-1]:
Default output format [json]:
File : deptno.json 
{
  "dept": [
    {
      "PutRequest": {
        "Item": {
          "deptno": {"S": "10"},
          "dname": {"S": "Sales"}
        }
      }
    },
    {
      "PutRequest": {
        "Item": {
          "deptno": {"S": "20"},
          "dname": {"S": "Marketing"}
        }
      }
    },
    {
      "PutRequest": {
        "Item": {
          "deptno": {"S": "40"},
          "dname": {"S": "Constuction"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "50"},
          "dname": {"S": "Tax"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "60"},
          "dname": {"S": "travel"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "70"},
          "dname": {"S": "service"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "80"},
          "dname": {"S": "Bus"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "90"},
          "dname": {"S": "tram"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "100"},
          "dname": {"S": "train"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "110"},
          "dname": {"S": "taxy"}
        }
      }
    },
{
      "PutRequest": {
        "Item": {
          "deptno": {"S": "120"},
          "dname": {"S": "boat"}
        }
      }
    }
  ]
}

C:\Users\Administrator\Desktop\SofwareEngineering_E0>aws dynamodb batch-write-item --request-items file://dept.json --region us-east-1
{
    "UnprocessedItems": {}
}
records uploaded successfully.


Scan filter the records

Step10: You can able replicate the table as well, with different region click Globally choose your region, whenever the records are inserted in the your region it was reflected automatically 
Step11: you can choose the region click create.

Step12:replicating creating

Step13: table is creating other region 
Table created 
Step14:Delete one record the main region us-Virginia click delete 120 deptno

Step15:Repicate region deleted the record successfully 
Step16:reverse delete the dept 50 record in Europ(paris)

Step17:deleted record main region also us-virginia


Both ways possible delete, replicate tables
Step18: Delete the table source side us-virginia

Getting error  due toe replicate table exist ,so to delete first target side 

Step19:Target side table delete successfully.
Step20:Table deleted successfully, 
source side us-virginia

--Thanks 






No comments:

Post a Comment