Amazon DynamoDB - Hands On Demo

Step 1: Create a table

In this step, you create a Music table in Amazon DynamoDB. The table has the following details:

  • Partition key — Artist

  • Sort key — SongTitle

 

To create a new Music table using the DynamoDB console:

  1. Sign in to the AWS Management Console and open the DynamoDB console at https://console.aws.amazon.com/dynamodb/.

  2. In the navigation pane on the left side of the console, choose Dashboard.

  3. On the right side of the console, choose Create Table.

  4. Enter the table details as follows:

    1. For the table name, enter Music.

    2. For the partition key, enter Artist.

    3. Enter SongTitle as the sort key.

    4. Leave Default settings selected.

  5. Choose Create to create the table.

  6. Once the table is in ACTIVE status, it's considered best practice to enable Point-in-time recovery for DynamoDB on the table by performing the following steps:

    1. Click the table name to open the table.

    2. Click Backups.

    3. Click the Edit button in the Point-in-time recovery section.

    4. Click the checkbox to turn on point-in-time recovery, then click the Save changes button.

Music
Artist
SongTitle

Follow these steps to write data to the Music table using the DynamoDB console.

  1. In the navigation pane on the left side of the console, choose Tables.

  2. In the table list, choose the Music table.

  3. Select Explore Table Items.

  4. In the Items view, choose Create item.

  5. Choose Add new attribute, and then choose Number. Name the field Awards.

  6. Repeat this process to create an AlbumTitle of type String.

  7. Enter the following values for your item:

    1. For Artist, enter No One You Know as the value.

    2. For SongTitle, enter Call Me Today.

    3. For AlbumTitle, enter Somewhat Famous.

    4. For Awards, enter 1.

  8. Choose Create item.

  9. Repeat this process and create another item with the following values:

    1. For Artist, enter Acme Band.

    2. For SongTitle enter Happy Day.

    3. For AlbumTitle, enter Songs About Life.

    4. For Awards, enter 10.

  10. Do this one more time to create another item with the same Artist as the previous step, but different values for the other attributes:

    1. For Artist, enter Acme Band.

    2. For SongTitle enter PartiQL Rocks.

    3. For AlbumTitle, enter Another Album Title.

    4. For Awards, enter 8.

Awards
AlbumTitle
No One You Know
Call Me Today
Somewhat Famous
1
Acme Band
Happy Day
Songs About Life
10
Acme Band
PartiQL Rocks
Another Album Title
8

Step 3: Read data from a table

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Select the Explore table items.

  4. On the Items tab, view the list of items stored in the table, sorted by Artist and SongTitle. The first item in the list is the one with the Artist Acme Band and the SongTitle Happy Day.

Step 4: Update data in a table

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Choose View items.

  4. Choose the item whose Artist value is Acme Band and SongTitle value is Happy Day.

  5. Update the AlbumTitle value to Updated Album Title, and then choose Save.

Updated Album Title

Step 5: Query data in a table

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Choose View items.

  4. Choose Query.

  5. For Partition key, enter Acme Band, and then choose Run.

Acme Band

Step 6: Create a global secondary index

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Choose the Indexes tab for the Music table.

  4. Choose Create index.

  5. For the Partition key, enter AlbumTitle.

  6. For Index name, enter AlbumTitle-index.

  7. Leave the other settings on their default values and choose Create index.

AlbumTitle
AlbumTitle-index

Step 7: Query the global secondary index

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Select the View items.

  4. Choose Query.

  5. In the drop-down list under Query, choose AlbumTitle-index.

    For AlbumTitle, enter Somewhat Famous, and then choose Run.

Somewhat Famous

Step 8: clean up resources

 

  1. In the navigation pane on the left side of the console, choose Tables.

  2. Choose the Music table from the table list.

  3. Choose the Indexes tab for the Music table.

  4. Choose Delete table.

Thanks

For

Watching

Amazon DynamoDB - Hands On Demo

By Deepak Dubey

Amazon DynamoDB - Hands On Demo

  • 49