> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to AWS DynamoDB

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/introduction-to-aws-dynamodb" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through Amazon DynamoDB features. We will create a table in Amazon DynamoDB to store information and then query that information from the DynamoDB table.
2. Duration: **30 minutes**
3. AWS Region: **US East (N. Virginia) us-east-1.**

### Introduction

#### What is AWS DynamoDB?

##### Definition

* DynamoDB is a fast and flexible NoSQL database designed for applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed database, and it supports both document and key value data models.
* It has a very flexible data model. This means that you don't need to define your database schema upfront. It also has reliable performance.
* DynamoDB is a good fit for mobile gaming, ad-tech, IoT and many other applications.

##### DynamoDB Tables

DynamoDB tables consist of

* Items (Think of a row of data in a table).
* Attributes (Think of a column of data in a table).
* Supports key-value and document data structures.
* Key= the name of the data.  Value= the data itself.
* The document can be written in JSON, HTML, or XML.

DynamoDB- Primary Keys

* DynamoDB stores and retrieves data based on a Primary key
* DynamoDB also uses Partition keys to determine the physical location data is stored.
* If you are using a partition key as your Primary key, then no items will have the same Partition key.
* Composite Keys (Partition Key + Sort Key) can be used in Combination.
* Two items may have the same partition key, but must have a different sort key.
* All items with the same partition key are stored together and then sorted according to the sort key value.
* DynamoDB allows you to store multiple items with the same partition keys.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/001.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=393fdbd3edce2b6a0304849c661cec93" alt="" width="1540" height="800" data-path="images/labs/introduction-to-aws-dynamodb/001.png" />

### Tasks Details

1. Sign in to AWS Management Console.
2. Create a DynamoDB table.
3. Insert data into that DynamoDB table.
4. Search for an item in the DynamoDB table.
5. Validation of the lab

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM username**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## Lab guide

### Lab steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

* Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. Otherwise, you cannot proceed with the lab.
* Now copy your **Username** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign-in** button.

3. Once Signed In to the AWS Management Console, make the default AWS Region as **US East (N. Virginia) us-east-1.**

<Note>
  If you face any issues, please go through [**FAQs and Troubleshooting**](/aws-cp/support/faqs-and-troubleshooting).
</Note>

#### Task 2: Create DynamoDB Table

In this task, we are going to create a DynamoDB table.

1. Make sure you are in the **US East (N. Virginia) us-east-1** Region.
2. Navigate to **DynamoDB** page by clicking on the **Services** menu at the top. DynamoDB is available under the **Database** section.
3. Click on **Create table** button

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/002.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=ed5ff562616d57ed01d07738e043946a" alt="" width="486" height="237" data-path="images/labs/introduction-to-aws-dynamodb/002.png" />

* Table Name: Enter **mydynamodbtable**
* Partition key: Enter **companyid** and select **Number**
* Add sort key: Enter **name** in the respective field and select **String**.

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/003.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=035f29d9c362476e4892645251410d20" alt="" width="1314" height="512" data-path="images/labs/introduction-to-aws-dynamodb/003.png" />
* The combination of a Partition Key and a Sort Key uniquely identifies each item in a DynamoDB table.
* Leave all the other settings as default and then click on **Create table**.

4. Your table will be created within 2–3 minutes.

#### Task 3 : Inserting Data into DynamoDB Table

In this task, we are going to insert data into a DynamoDB table. By adding data to the table, we will understand how to populate it with relevant information.

1. Next, we are inserting data in the table we created.
2. Select **mydynamodbtable** and then Click on the **Explore table items** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/004.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=d03698cb1e4f9f14ab814cd5f7237bdc" alt="" width="1530" height="775" data-path="images/labs/introduction-to-aws-dynamodb/004.png" />

3. Now click on **Create item** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/005.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=eff664cc853b2e865450e8a0027e13e7" alt="" width="1027" height="374" data-path="images/labs/introduction-to-aws-dynamodb/005.png" />

4. Add new Partition key and sort key values.

   * companyid     : Enter **1**
   * name        : Enter **John**
5. After entering the data, click on the **Create item** button, present on the right bottom corner.
6. For testing purposes, add 4–5 items as shown in the above step and click on the **Create item** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/006.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=eb2d6f16ba840ddfa9e3bfcd6e39c26a" alt="" width="1027" height="492" data-path="images/labs/introduction-to-aws-dynamodb/006.png" />

#### Task 4 : Search for Items in the Table

In this task, we are going to query capabilities of DynamoDB. By using the scan operation.

1. We will query the items in our table by using **scan**.
2. Select **Query**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/007.png?fit=max&auto=format&n=f-UHpNVYYLl5zeE0&q=85&s=5fedcb3700b15e1482c863bec916faa0" alt="" width="1027" height="518" data-path="images/labs/introduction-to-aws-dynamodb/007.png" />

3. In the query window, enter the partition key and sort key which you want to search.

   * Partition Key = Enter **4**
   * Sort Key = Enter **Sarah**
   * Click on **Run**.
4. You will be able to see a result table with your filtered records. A sample screenshot is given below:

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/008.gif?s=dd1139c2ecacd89713a2b6ef152a714c" alt="" width="1000" height="514" data-path="images/labs/introduction-to-aws-dynamodb/008.gif" />

5. You can search with the Partition Key and the Sort Key. Try some additional test cases yourself to become more familiar with these keys.

<Tip>
  **Do you know?**

  DynamoDB was originally developed by Amazon to meet the demands of their e-commerce platform during the holiday shopping season. The system needed to handle the sudden spike in traffic and maintain low latency for a large number of concurrent users. DynamoDB's design principles and scalability were tested and proven in this high-stakes environment, ensuring its reliability and performance even under extreme load conditions.
</Tip>

#### Task 5 : Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the left side panel.
2. This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
3. Sample output :

<img src="https://mintcdn.com/ip-cloud-architect-pathway/f-UHpNVYYLl5zeE0/images/labs/introduction-to-aws-dynamodb/009.gif?s=3c3c45b808f2748eb625453e4777cc96" alt="" width="1000" height="438" data-path="images/labs/introduction-to-aws-dynamodb/009.gif" />

### Completion and conclusion

1. You have successfully created an Amazon DynamoDB table.
2. You have inserted multiple items into the table using a partition key and sort key.
3. You have successfully searched for items in the table using the partition and sort keys.

### End lab

1. Sign out from the AWS Management Console.
2. Click on **End lab** button in the IP Lab Portal and wait till the process gets completed

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Create Amazon DynamoDB Table** — Check whether a DynamoDB Table is created or not.
* **Create Items in DynamoDB Table** — Check whether items in the DynamoDB table are created or not.

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
