How to Create a Basic DynamoDB Setup

By John Paul Mueller

You have a number of ways to work with DynamoDB and AWS. For example, you can go with the local option. However, the local option is really only good for experimentation. If you want to start creating a production system, you need to get onto AWS and perform the required tasks in the cloud.

Before you can do anything with DynamoDB, you must create an instance of it, just as you do for RDS. The following procedure helps you get started with DynamoDB so that you can perform some interesting tasks with it:

  1. Sign into AWS using your user account.
  2. Navigate to the DynamoDB Management Console.

    You see a Welcome page that contains interesting information about DynamoDB and what it can do for you. However, you don’t see the actual console at this point. Notice the Getting Started Guide link, which you can use to obtain access to tutorials and introductory videos.

  3. Click Create Table.

    You see the Create DynamoDB Table page. Amazon assumes that most people have worked with an RDBMS database, so the instructions for working with RDS are fewer and less detailed. Notice the level of detail provided for DynamoDB. The wizard explains each part of the table creation process carefully to reduce the likelihood that you will make mistakes.

    table characteristics AWS
    Start defining the characteristics of the table you want to create.
  4. Type TestDB in the Table Name field.

    Pick a descriptive name for your table. In this case, you need to remember that your entire database could consist of a single, large table.

  5. Type EmployeeID in the Primary Key field and choose Number for its type.

    When working with a NoSQL database, you must define a unique value as the key in the key-value pair. An employee ID is likely to provide a unique value across all employees. Duplicated keys will cause problems because you can’t uniquely identify a particular piece of data after the key is duplicated.

    A key must also provide a simple value. When working with DynamoDB, you have a choice of making the key a number, string, or binary value. You can’t use a Boolean value because you would have only a choice between true and false. Likewise, other data types won’t work because they are either too complex or don’t offer enough choices.

    Notice the Add Sort Key check box. Selecting this option lets you add a secondary method of locating data. Using a sort key lets you locate data using more than just the primary key. For example, in addition to the employee ID, you might also want to add a sort key based on employee name. People know names; they tend not to know IDs. However, a name isn’t necessarily unique: Two people can have the same name, so using a name as your primary key is a bad idea.

    The default settings create a NoSQL table that lacks a secondary index, allows a specific provisioned capacity, and sets alarms for occasions when applications exceed the provisioned capacity. A provisioned capacity essentially determines the number of reads and writes that you expect per second. Given that this is a test setup, a setting of 5 reads and 5 writes should work well. Read more about provisioned capacity in this AWS article.

  6. Select Add Sort Key.

    You see another field added for entering a sort field. Notice that this second field is connected to the first, so the two fields are essentially used together.

    sort key AWS
    Choose a sort key that people will understand well.
  7. Type EmployeeName in the sort key field and set its type to String.
  8. Click Create.

    You see the Tables page of the DynamoDB Management Console. Each of the tabs tells you something about the table. The More link on the right of the list of tabs tells you that more tabs are available for you to access.

    Click the right-pointing arrow to show the Navigation pane, where you can choose other DynamoDB views (Dashboard and Reserved Capacity).

    Table page AWS
    The table you created appears in the Tables page.