Create and Manage a Nonrelational Database

with Amazon DynamoDB

Module 1: Application Background

To get started, you will explore the tutorial prerequisites

Overview

Imagine that you are building an online bookstore application. Your bookstore has a large inventory of books that are stored in your warehouse to be sold to customers. The application must show users the books that are available for sale as well as some basic information about the book, such as its author.

The application needs to retrieve a specific book by its title and author so that a user can drill in for more detail when looking at a book. Furthermore, your application should allow users to browse all books in a particular category, such as history or biography, to allow for discoverability of interesting books.

Finally, you may carry different formats of a book, such as hardcover, paperback, or audiobook. Your application should store the formats you have in stock for a book with a mapping to the item number in your inventory system. Your application should allow these formats to be updated over time, as you may add or remove formats for a book.

In the modules in this tutorial, you learn how to model a DynamoDB table to accommodate these application needs.

To complete this tutorial, you need an AWS account and access to create AWS Identity and Access Management (IAM), Amazon DynamoDB, and AWS Cloud9 resources in that account. The step-by-step guide in this tutorial explains how to set up all prerequisites.

 Time to complete

15 minutes

Implementation

  • Use a personal account or create a new AWS account for this tutorial rather than using an organization’s account to ensure that you have full access to the necessary services and do not leave behind any resources from the tutorial.
  • AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug code with just a browser. AWS Cloud9 includes a code editor, debugger, and terminal. It also comes prepackaged with essential tools for popular programming languages and the AWS Command Line Interface (CLI) preinstalled so that you don’t have to install files or configure your laptop for this tutorial. Your AWS Cloud9 environment will have access to the same AWS resources as the user with which you signed in to the AWS Management Console.

    To set up your AWS Cloud9 development environment:

    1. Navigate to the AWS Management Console. Enter Cloud9 in the search bar and select Cloud9 to open the console. Choose Create environment.

    2. Choose Create environment.

    3. Enter DynamoDB Deep Dive in the Name box. Optionally, enter a Description and choose Next step.

    4. Leave the Environment settings at their defaults to create a new t2.micro EC2 instance, which will be hibernated after 30 minutes of inactivity.

    5. Choose Next step.

    6. Review the environment name and settings, and choose Create environment. Your environment will be provisioned and prepared after several minutes.

    7. Once ready, your IDE will open to a welcome screen.

    You should now see your AWS Cloud9 environment. There are three areas of the AWS Cloud9 screen to know, as illustrated in the following screenshot:
    • File explorer: On the left side of the screen, this shows a list of the files in your directory.
    • File editor: The large main area of the screen is where you view and edit files that you’ve selected in the file explorer.
    • Terminal: On the lower right portion of the screen, this is where you run commands to execute code samples.
    AWS Cloud9 Console
  • In these modules, you use Python scripts to interact with the DynamoDB API.

    Run the following commands in your AWS Cloud9 terminal to download the scripts and install the application dependencies:

    1. Download and unpack the module code by running the following command in the AWS Cloud9 terminal

    curl -sL https://s3.amazonaws.com/ddb-deep-dive/dynamodb.tar | tar -xv

    2. To install Boto 3, run the following command in the AWS Cloud9 terminal.

    pip install --user boto3

    You are now ready to start this tutorial. In the next module, you insert items into and retrieve items from your DynamoDB table.

Was this page helpful?

Inserting and Retrieving Data