Linux | Cloud | DevOps | Scripting

Breaking

Saturday 27 July 2019

About DynamoDB



DynamoDB is a fast, fully managed NoSQL database service that's suitable for document and key-value store models. Basically, DynamoDB used for the applications that need consistent single-digit millisecond latency at any scale. DynamoDB allows us to create a database table that can store and retrieve any amount of data. 

Benefits of DynamoDB:

1. DynamoDB always stored on SSD storage.
2. DynamoDB spread across three geographically distinct data centers. SO, we can get high availability
3. DynamoDB is fast, flexible and suited for read-heavy applications

Consistency Types:

DynamoDB provides two different types of read consistency:
1. Eventually Consistent Reads (default)
2. Strongly Consistent Reads

At the time of table creation in DynamoDB, we define the capacity that we want to reserve for read and writes. For write throughput charge per hour for every 10 units of write capacity and this equates to 36,000 writes per hour. For read throughput, there is a charge per hour for every 50 units of read capacity and this equates to 180,000 strongly consistent reads or 360,000 eventually consistent reads.

Create a table and search for data in DynamoDB:

Steps we need to follow:

1. Create a table in DynamoDB database.
2. Create items in the table
3. Scan and Search the data from Table

Step 1: Create a table in DynamoDB database:

AWS ➔ Services ➔ DynamoDB ➔ Create table ➔ Table name: students ➔ Primary key: stu_id (A primary key is a special relational database table column designated to uniquely identify all table records) ➔ from drop-down list select numbers because normally output of stu_id is numeric. But if this is Alpha-numeric, we should use a string ➔ we can add one sort key, just by having a tick in the checkbox on Add sort key ➔ leave a tick in the checkbox of Use default settings but if you want to customize by yourself, just untick this…

Create DynamoDB Table
Fig: Create DynamoDB Table

…as we untick default settings, some more attributes will be shown on screen for customization ➔ provide all customizations, which you want to use. I am using Minimum provisioned capacity 1 unit for Read Capacity and 1 unit for Write capacity ➔ Add tags: provide tags here ➔ Create.

After creation in 'Table details' you can see the overview of our table.

Table Details
Fig: Table Details

Step 2: Create items in the table:

Select the table ➔ Items ➔ Create item…

Create Item
Fig: Create Item

…here, we can see 'stu_id' is already mentioned. This is the Primary key, which we defined at the time of table creation. Value: 001 ➔ to add an item click on '+' icon ➔ there are three attributes listed 'Append', 'Insert' and 'Remove'. Insert will create an item above pre-created item; that is stu_id in this case and Append will create an item below the pre-created item ➔ as you click on 'Append', a drop-down list will appear, from which we need to select the Data-type. I am selecting string ➔ in field provide one more row, 'first_name' ➔ Value: Tom ➔ again click on that '+' icon ➔ Append ➔ String ➔ Field: last_name ➔ Value: Hardy ➔ click on '+' icon ➔ Append ➔ String ➔ Field: class ➔ BCA ➔ click on '+' icon ➔ Append ➔ List ➔ Field: year ➔ Append ➔ Number ➔ 2 ➔ Save.

As we click on 'Save' our one row will create. Similarly, create some more rows to create a final table. In the below-shown figure you can see my created figure:

Database
Fig: Database


Step 3: Scan and Search the data from Table:

AWS ➔ Services ➔ DynamoDB ➔ Tables ➔ Select Table ➔ Items ➔ as we click on Scan, a drop-down list will appear listing 'Scan' and 'Query' ➔ select query if you want to query something otherwise select scan ➔ Add filter…

Now, we want to list the people who are in BCA:

…Enter attribute: class ➔ operators, we use operators if there is a condition in our search criteria. By default it is only an 'equal to (=) symbol' ➔ Value: BCA ➔ Start search.

As we click on 'Start search' we get the result as shown in the figure:

Search in Data
Fig: Search in Data

We can search multiple queries together using Add filter option; like now if we want to list the people who are in the 3rd year of MCA. We will query like:

Select table ➔ Add filter ➔ Attribute: class ➔ Data type: string ➔ Operator: = ➔ Value: MCA ➔ again click on 'Add filter' ➔ Attribute: year ➔ Data type: Number (make sure you selected 'Number' Data-type) ➔ Operator: = ➔ Value: 3 ➔ Start search.

As per our table, we will get one result (shown in the figure):

Multiple Search in Data
Fig: Multiple Search in Data





2 comments:

Pages