What You’ll Learn:Gain and understanding of what a ‘keyspace’ is in Cassandra and its similarities to a database schema, as well as creating tables in your Cassandra database.

 

 

In Cassandra, a keyspace is a container for your application data. It is similar to the schema in a relational database.

 

  • From the CQL shell, type:

your result should be:

 

The keyspace can include operational elements, such as replication factor and data center awareness. Let’s create a keyspace called “demo”. We will include replication strategy class and factor; details that will be covered in a future tutorial.

  • To create the keyspace “demo”, at the CQL shell prompt, type:

  • To use the keyspace we’ve just created, type:

 

Now we have we have a keyspace, we can create tables within that keyspace to store our data in. Tables, or column families, consist of columns and rows.

  • Create a “users” table within the keyspace “demo” so that we can insert some data into our database:

 

We have created a table with a single primary key, lastname.

  • To see the various attributes of the users table we have just created, type:

Next