- Now let's review a demo
of creating an Amazon DynamoDB table.
From the console dashboard,
we will go to DynamoDB
And of course, we don't have any tables in this region yet.
So before we create a table,
I just wanna show you in the documentation
Let me just switch tabs here.
In the AWS documentation for Dynamo DB,
you can find example tables and example data.
So if you know, being new to DynamoDB, if you want to,
you know learn more about programming
against that particular data store,
then you can look at the documentation
for example tables and data,
and example indexes
and other kinds of things.
So, we will go ahead and use Product Catalog
for our table name.
And we will use ID as a number for the primary key.
All right. So I'll go ahead and copy that.
And then we'll say create table.
And then we'll use Product Catalog for the table name.
And then DynamoDB being schema-less does not require us
to specify the columns.
Every item that we add to that table could have completely
different attributes or columns.
That probably wouldn't work very well for our application.
But as far as DynamoDB is concerned, you know it's doesn't
enforce any kind of schema except for the Primary Key.
And so again, here in the documentation, the Primary Key
is just a simple ID as a number.
You could use other fields for the form table.
It would be named as a 'String'.
And then you can also make a Composite key,
and the Composite key would be a combination of
two different fields.
And then of course, if you define these as being a part of
the primary key, then that is really the only part of the
schema that you might think of that is enforced.
So every item would have to have an attribute
with that particular name on it,
and it would have to be unique.
So, let's go back here to the table and say,
'ID' as a Number
and if we were to create one of those
other tables that have a composite key,
then the composite key, it would be a composite
of the partition key plus a sort key.
Uh, we won't worry about that for now.
We will just keep it simple.
And then of course down here, it says
we could 'Use default settings'.
And the default settings are:
No secondary indexes, we'll talk more about those
in a later lesson.
And then we're gonna set Provisioned capacity
to 5 reads and 5 writes.
For a demo and if you were just creating
like a Dev environment, then that's probably fine.
You could probably even go as low as um
If we wanted to have more control over this,
then we could go to probably even
looks like they're not gonna let us go lower than that.
But even that is only gonna cost us about three dollars
a month in capacity.
We do have the option to turn on Auto-Scaling,
so that DynamoDB can scale the capacity.
Remember what we're paying for is a combination of
Read capacity units and Write capacity units.
And so you know, if what's actually happening
is greater than or less than what we're paying for
then we can use auto-scaling to help match
you know, what is provision with what is actually happening.
And that could, you know save us money.
So I'm gonna turn those off.
We actually don't really have a need for that in this demo.
But in a production use case, you may very well want that.
We also have the ability to encrypt our data at rest.
All right. So here the default is to use
an AWS owned Customer Master Key.
Or you can use KMS.
And this is a managed Customer Master Key using underneath
the KMS service.
And then of course, we can go create the table
and it says 'Table is being created'.
So let's go ahead. It usually doesn't take very long.
So again, we don't have to necessarily
refresh the whole screen.
Most services give us this little refresh button.
And there we go, just like that.
Uh, pretty quick.
And so, now we can review those table details.
We have our table name, then our primary key is
ID(Number), and then we're using KMS
to help with encryption at rest.
Uh, let's see here.
And then we have provisioning 5 reads, 5 writes
with auto-scaling disabled.
And of course, this table is living in the Ohio region.
And then again, I've mentioned this earlier,
the Amazon Resource Name, the ARN, you may very well
need to refer to this in your code.
This is an important attribute of this table is the ARN.
That's how we would identify in our code that
that's the table we want to write to.
Now in terms of storage,
you'll notice that we did not need to specify storage.
And that's because we don't provision storage
within DynamoDB.
Uh, storage just grows automatically and the storage plane
just auto-scales, um as we add more data,
DynamoDB just adds more resources to hold that data.
And you can see here that we don't have any items
in this table yet uh, right.
So let's go ahead and do that real quick.
I'm going to open up the console or open up my terminal
and use this sample data that this developer guide gives us
some sample data here. And I'm gonna open up the terminal
and use the Command line interface
to quickly load a number of records into that table.
All right, so with my terminal in place,
now we can...
I'll show you that I have a folder over here
called Sample Data. And in there, we have a few
Json files that Amazon gives us. You can download that
from the website, from the documentation.
You can generally download .zip files of sample data.
And they would show you exactly what to do
in order to load that. And of course, you can use these
kinds of things to automate the creation and population
of tables. And you don't have to do it with the CLI.
These are showing you how to do it the CLI tools.
But you can do it with the CSDKs, and AWDS, you know
provides SDKs for most of the popular languages.
So, we'll go ahead and
we'll go ahead and copy that,
and we'll go back to our terminal and we'll go ahead
and try this. So we're saying we're going to use the
AWS CLI tools with using the DyanamDB service
to write a number of items.
We're doing a batch write, and we're saying that we're using
the ProductCatalog Json here.
So let's go ahead and try that.
There we go. And know it's telling us the fact
that we saw this as opposed to an error,
means that that data should've loaded.
And had we'd gotten an error,
we would've of course seen that.
So let's go back to our DynamoDB,
and if we do a refresh here, there we go.
We have some records in there.
And we will continue to explore this.
We will take a look at Scan and Query operations.
The ability to query this table for particular items.
We will look at that here in an upcoming demo.