Difficulty: Beginner
Estimated Time: 10 minutes

In this learning unit, you will:

  • Create keyspaces using the CQL CREATE KEYSPACE statement
  • Understand data replication strategies SimpleStrategy and NetworkTopologyStrategy
  • Learn how to select a data replication strategy and replication factor
  • Practice several useful CQL statements and CQL shell commands that work with keyspaces

In this scenario, you learned about:

  • Keyspaces and the CQL CREATE KEYSPACE statement
  • Data replication strategies SimpleStrategy and NetworkTopologyStrategy
  • Selecting a data replication strategy and replication factor
  • Useful CQL statements and CQL shell commands that work with keyspaces

Keyspaces and Data Replication Strategies

Step 1 of 8

Keyspace

A keyspace is a namespace for a set of tables sharing a data replication strategy and some options. It is conceptually similar to a "database" in a relational database management system. Tables, materialized views, indexes and other schema objects are always defined within a keyspace.

To create a keyspace, Cassandra Query Language has the CREATE KEYSPACE statement with the following simplified syntax:

CREATE KEYSPACE [ IF NOT EXISTS ] keyspace_name
    WITH REPLICATION = { replication_map };

A keyspace name can contain alphanumeric characters and underscores. By default, names are case-insensitive, but case sensitivity can be forced by using double quotation marks around a name.

A replication map specifies a data replication strategy and replication factors. SimpleStrategy and NetworkTopologyStrategy are two available choices for prototyping/learning and production, respectively.