liveBook · Manning

Keyspace

As explained in ScyllaDB in Action

A keyspace is a ScyllaDB or Cassandra namespace that contains tables and defines settings such as replication and durable writes.

A keyspace is the top-level home for related ScyllaDB tables. It groups tables and sets how their data is replicated across a cluster; its durable-writes setting is also part of its definition. Think of it as roughly like a relational database or schema, but with cluster-wide replication configuration attached. section 2.2.1 section 2.2.2

The hierarchy is keyspace, table, partition, then row. A table’s primary key determines its partitions, and partitions are the units replicated to cluster nodes. Keyspace replication settings therefore affect every table stored inside it, while primary-key design determines how each table distributes its rows. section 2.2.1 section 2.5

Create and work with a keyspace in CQL:

  • Run CREATE KEYSPACE with a meaningful name and a replication configuration before creating tables. section 2.2.2
  • Use DESCRIBE to inspect the CQL definition, including replication and durable_writes. section 2.2.2
  • Run USE keyspace_name to make unqualified table names refer to that keyspace. section 4.1.1
  • Choose replication deliberately: SimpleStrategy is suitable for a learning playground but flagged as unsuitable for production. section 2.2.2 section 5.2

Restaurant-review keyspace

A reviews keyspace can hold the tables for a review application. Create the keyspace with its replication settings first, select it with USE reviews, and then create the application tables. For a disposable data-type playground, a separate types keyspace can use replication_factor 1. section 5.2 section 4.1.1 section 5.3

Figure 2.3 ScyllaDB consists of rows, identified by primary keys and grouped into partitions, which are grouped into tables, which are grouped into keyspaces.
figure

Use the hierarchy diagram to locate a keyspace above tables, partitions, and rows, and to connect replication settings with the data those tables contain. section 2.2.1

How ScyllaDB in Action covers it

How deep it goes
Explains creation, inspection, selection, and replication choices, while deferring nuanced production replication strategies.
Examples
Uses initial, types, and reviews keyspaces for food reviews, data-type experiments, and application tables.
What it assumes
Starts from familiar relational table concepts while distinguishing distributed partitioning and replication.
What you can do after
Operate/configure it with CREATE KEYSPACE, DESCRIBE, and USE commands while choosing a replication configuration.
How it connects
Connects keyspaces to tables, primary keys, partitions, replication, CQL, and query-first design.

Also explained in

Compare how 2 books explain keyspace →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ScyllaDB in Action. The section links point to the parts of the book it draws on.