A database and schema
A Cassandra database schema has two major building blocks: Keyspace, Column Family and Primary Key for Column Family. Let's discuss them in some detail.
Keyspace
In previous chapters we learned that similar to RDBMS database Cassandra Keyspace is a namespace that logically contains a set of tables. A keyspace has there configuration options;
- Replication Strategy
- Replication Factor
- The
durable_writes
Former two options we already discussed in previous chapter. The durable_writes option lets you to enable or disable the option of using commit log for updates. By default durable_writes
is enabled and its suggested to keep this enabled.
We know how to create a keyspace but what if the keyspace already exists. in such case Cassandra will return error. However we can use IF NOT EXISTS
option to disable error; using IF NOT EXISTS
option Cassandra will do nothing if keyspace exists otherwise it'll create it:
CREATE KEYSPACE IF NOT EXISTS cassandrademodb WITH replication...