Skip to main content

DynamoDB Tables and Global Secondary Indexes

Hands-On Lab

 

Photo of Fernando Medina Corey

Fernando Medina Corey

Training Architect

Length

00:30:00

Difficulty

Beginner

In this hands-on lab, we'll learn how to use Global Secondary Indexes to efficiently query the data inside of DynamoDB tables using values other than the primary key.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

DynamoDB Tables and Global Secondary Indexes

Introduction

In this hands-on lab, we'll learn how to use global secondary indexes (GSIs) to efficiently query the data in DynamoDB tables using values other than the primary key.

Log in to the AWS Management Console with the credentials provided on the lab instructions page. Make sure you are using the us-east-1 (N. Virginia) region.

In a new browser tab or window, log in to the Jupyter Notebook with the credentials provided on the lab instructions page.

Create a DynamoDB Table

  1. In the Jupyter Notebook, select the first code cell and click Run.
  2. Select the second code cell and click Run.
  3. Select the third code cell and click Run.
  4. In your AWS Management Console tab, navigate to the DynamoDB service.
  5. Click Tables in the left sidebar.
  6. Click the Movies table name, then click the Items tab in the right sidebar.
  7. In the Jupyter Notebook, select the fourth code cell and click Run.
  8. In the AWS Management Console, click the refresh button on the upper right side of the table menu.
  9. In the Jupyter Notebook, select the fifth code cell and click Run.
  10. Select the sixth code cell and click Run.

Create a Global Secondary Index

  1. In the Jupyter Notebook, select the seventh code cell and click Run.
  2. Wait until the Movies table in the AWS Management Console finishes updating (it may take a few minutes).
  3. In the Movies menu on the right side of the screen, click More > Indexes.
  4. Verify that rating-title-index is listed as a global secondary index and that its status is Active.
  5. Go back to the Jupyter Notebook.
  6. Select the eighth code cell and click Run.

Conclusion

Congratulations, you've successfully completed this hands-on lab!