DEMO: Creating a Keyspace and Table in Amazon Keyspaces (for Apache Cassandra)


Course Introduction
RDS vs. EC2
RDS vs. EC2
DynamoDB Accelerator

The course is part of this learning path

Start course
4h 21m

This section of the AWS Certified Solutions Architect - Professional learning path introduces you to the AWS database services relevant to the SAP-C02 exam. We then understand the service options available and learn how to select and apply AWS database services to meet specific design scenarios relevant to the AWS Certified Solutions Architect - Professional exam. 

Want more? Try a Lab Playground or do a Lab Challenge

Learning Objectives

  • Understand the various database services that can be used when building cloud solutions on AWS
  • Learn how to build databases using Amazon RDS, DynamoDB, Redshift, DocumentDB, Keyspaces, and QLDB
  • Learn how to create ElastiCache and Neptune clusters
  • Understand which AWS database service to choose based on your requirements
  • Discover how to use automation to deploy databases in AWS
  • Learn about data lakes and how to build a data lake in AWS

Hello and welcome to this lecture, which will be a demonstration on how to create an Amazon Keyspaces database. And what I shall do, I shall create a keyspace and then a table that resides in that keyspace. So let's take a look.

So firstly, scroll down to the database category and then select Amazon keyspaces. As you can see, I don't have any keyspaces set up at the moment so I just need to click get started. Now much like in the QLDB demonstration, Amazon keyspaces also has a quick getting started guide that gives you a quick tutorial on how to create a keyspace, then how to create a table in your keyspace and then how to populate it with data and query your data.

As this is a fundamental level course, we're just going to create the keyspace and then create a table. Now I'm not going to use the getting started guide but if you'd like to explore this service further, then I recommend you going through those four steps.

Okay, so to create a keyspace we can select keyspaces on the left side here. Now remember a keyspace is essentially going to be a grouping of tables, that will be used by your applications to read all my data to. And it also defines how the replication is managed as well.

So from here, we simply click create keyspace. Now we need to give it a name, I'm just gonna call this; my keyspace. We can add any optional tabs if we'd like to. And this is the query that will be executed to create the keyspace that we specified above. So we can say this is going to create the name of my keyspace and it will also manage the replication across a single region strategy. So AWS will configure this replication for us across multiple availability zones. Click create keyspace and then we can see it's active. So it's very easy to create the keyspace.

Now we need to create a table within that keyspace. So if we now select that keyspace, we can see that it doesn't have any tables. Now the table itself, is where your database rights are stored. So now we need to create a table within the keyspace. So select create table. We can select the keyspace that we want this table to belong to. As we only have one, that's the my keyspace that we just created.

Now we can enter a table name. I'll just call this my table. Here, we can enter the schema information. So we can enter any columns that we want, for example; product name and then the type field for that column. As you can see, there's lots of different types that you can use. For this, I'll just use the character string. And if we want more than one column, we can add another column. For example; product ID, and this can be a decimal field.

Now we can add our partition key and we can see that a partition key is composed of one or more columns that are used to uniquely identify rows within a table. So we can select the columns that we'd like to act as the partition key. So as you can see, you can add more than one column. We then have clustering columns, which is optional, and this helps you to sort data within a partition.

For this demonstration, I'm not gonna have any clustered columns. Then if you scroll down to the read and write capacity settings, here we have the on-demand and provision modes that I discussed in a previous lecture. So the on-demand option simplifies billing for the actual read and writes that the application performs. Whereas provisioned, you can manage and optimize the reads and writes in advance.

So as you can see for read capacity, we can have this automatically scaling. I can set the minimum capacity units and the maximum capacity units. And when the utilization gets to 70%, it will automatically scale up. Similarly with the write capacity. You can copy the settings that you have above for the read scaling or you can set it manually.

So you can have different scaling patterns for both read and write capacity. I'm just gonna leave this as on-demand capacity mode, just for simplification. And then if we go down even further, we can see our point in time of recovery. We can either enable this or disable. It's always best to keep this enabled, just to allow you to recover from any incident at any point. Then you can add any optional tags. And finally, this just shows you the query that will be executed to create the table in keyspace, along with the column names and the types and also the primary key. And it also sets your capacity modes and the fact that we have point-in-time recovery enabled.

Once you're happy with all your options, simply select create table. And that has now created the my table in my keyspace. As you can see, the status is now active and if you select the table, you can see the partition key and your columns as well. And if you need to add any more columns, then you can do so here.

So that was just a very quick overview of how to firstly create a keyspace and then create a table. And finally, remember you can add additional tables to a keyspace. So if we go back into our keyspace, you can then go ahead and create an additional table within the same keyspace. And that's it for this demonstration.


Course Introduction - Amazon Redshift - DEMO: Creating an Amazon Redshift Cluster - Amazon Quantum Ledger Database (QLDB) - DEMO: Creating a Ledger using Amazon QLDB - Amazon DocumentDB (With MongoDB Compatibility) - DEMO: Creating an Amazon DocumentDB Cluster - Amazon Keyspaces (for Apache Cassandra) - Course Summary

About the Author
Learning Paths

Danny has over 20 years of IT experience as a software developer, cloud engineer, and technical trainer. After attending a conference on cloud computing in 2009, he knew he wanted to build his career around what was still a very new, emerging technology at the time — and share this transformational knowledge with others. He has spoken to IT professional audiences at local, regional, and national user groups and conferences. He has delivered in-person classroom and virtual training, interactive webinars, and authored video training courses covering many different technologies, including Amazon Web Services. He currently has six active AWS certifications, including certifications at the Professional and Specialty level.