Now, let's create our keyspace and a column family using the cqlsh
client. Run the command cqlsh
, then you should be on the cqlsh
prompt. On the cqlsh
prompt, run the keyspace creation command as follows:
cqlsh> CREATE KEYSPACE cassandrademodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 };
Here, we created a keyspace named cassandrademodb
. We chose the replication factor as 3
, so each data row we'll be creating will be stored on three nodes. Since, for now we're running our cluster on only one cluster, we chose the replication strategy as SimpleStrategy
.
Now, create one column family called users
in this keyspace. Here, we'll use username column as the partition key. Using the cqlsh
prompt we can create it as follows:
cqlsh> use cassandrademodb; cqlsh:cassandrademodb> CREATE TABLE songs ( username text PRIMARY KEY, email text, address text );
Here, we defined the username as a partition key as well as a primary key. However...