To build the backend for our notes app, it makes sense that we first start by thinking about how the data is going to be stored. We are going to use DynamoDB to do this.
Amazon DynamoDB is a fully managed NoSQL database that provides fast and predictable performance with seamless scalability. Similar to other databases, DynamoDB stores data in tables. Each table contains multiple items, and each item is composed of one or more attributes. We are going to cover some basics in the following chapters. But to get a better feel for it, here is a great guide on DynamoDB.
First, log in to your AWS Console and select DynamoDB from the list of services.
Select Create table.
Enter the Table name and Primary key info as shown below. Just make sure that
noteId are in camel case.
Each DynamoDB table has a primary key, which cannot be changed once set. The primary key uniquely identifies each item in the table, so that no two items can have the same key. DynamoDB supports two different kinds of primary keys:
- Partition key
- Partition key and sort key (composite)
We are going to use the composite primary key which gives us additional flexibility when querying the data. For example, if you provide only the value for
userId, DynamoDB would retrieve all of the notes by that user. Or you could provide a value for
userId and a value for
noteId, to retrieve a particular note.
To get a further understanding on how indexes work in DynamoDB, you can read more here DynamoDB Core Components.
If you see the following message, deselect Use default settings.
Scroll to the bottom, ensure that New role: DynamoDBAutoscaleRole is selected, and select Create.
Otherwise, simply ensure that Use default settings is checked, then select Create.
Note that the default setting provisions 5 reads and 5 writes. When you create a table, you specify how much provisioned throughput capacity you want to reserve for reads and writes. DynamoDB will reserve the necessary resources to meet your throughput needs while ensuring consistent, low-latency performance. One read capacity unit can read up to 8 KB per second and one write capacity unit can write up to 1 KB per second. You can change your provisioned throughput settings, increasing or decreasing capacity as needed.
notes table has now been created. If you find yourself stuck with the Table is being created message; refresh the page manually.
Next we’ll set up an S3 bucket to handle file uploads.