Apache Cassandra: Query-First Modeling and Tunable Consistency

A masterless ring where you design one table per query, choose your consistency per statement, and the tombstone is the thing that will surprise you.

Taught by Noshad Alam 7 lessons 59 min Published 30 Nov 2026

Cassandra is a masterless, linearly scalable, multi-datacentre database that keeps writing when nodes fail - and it achieves that by giving up almost everything a relational database gives you. There are no joins, no foreign keys, no aggregations worth the name, no `ORDER BY` on arbitrary columns, no transactions across partitions, and no way to filter on a column you did not plan for. What you get instead is a write path that is close to the theoretical minimum cost, a read path that is predictable when the data model is right, and an architecture where every node is identical and losing one is uneventful.

Overview

The language is CQL and it looks like SQL, which is the single most expensive resemblance in this programme. `SELECT ... WHERE ... ORDER BY` parses, so people write SQL habits into Cassandra and find out in production that a query they can express is a query they cannot afford. **Cassandra's model is query-first**: you enumerate the queries, then create **one table per query**, denormalising aggressively so that each query reads exactly one partition. A schema with five tables holding the same data five ways is not a mistake here - it is correct.

Two things carry the operational half of the course. **Tunable consistency**: every statement names a consistency level, and `R + W > RF` is the arithmetic that decides whether you get strong consistency - which means consistency is a per-query engineering decision rather than a property of the database. And the **LSM storage engine**, which makes writes cheap by never updating in place and hands you **tombstones** in exchange: deletes are written as markers, they accumulate, they are returned to the read path until compaction removes them, and a query that reads a hundred thousand tombstones to return nothing is the characteristic Cassandra incident.

Seven modules, about 95 hours. The capstone is a global event feed with time-bucketed partitions and consistency and failure experiments.

Introduction

This course assumes the programme's shared foundations and that you have met SQL. **It will go better if you have done the PostgreSQL course**, because much of what you learn here is in contrast to it.

For a sandbox, a **three-node cluster** - not one node - because consistency levels, replication and repair simply do not exist on a single node, and discovering that in Module 3 means redoing Module 1. Docker Compose with `cassandra:5` is the quickest route. **`ccm`** (Cassandra Cluster Manager) is excellent for running several nodes and multiple datacentres on one machine. Note that Cassandra wants memory: 2 GB of heap per node minimum, so a three-node cluster on a laptop needs care and a four-node one usually needs a bigger machine.

Use **`cqlsh`** throughout, and get into the habit of `TRACING ON` - Cassandra's tracing shows you the coordinator, the replicas contacted, the SSTables read and the tombstones scanned, which is the most instructive diagnostic in the system.

One framing to carry through. In a relational database, the data model is the truth and queries are views over it. In Cassandra, **the queries are the specification and the data model is derived from them**. If you do not know the queries, you cannot design the schema - and a query that was not anticipated usually means a new table and a backfill, not a new `WHERE` clause.

What you will be able to do

  • Explain the ring, token ranges, the coordinator and virtual nodes
  • Use CQL fluently, and name precisely where it differs from SQL
  • Design partition and clustering keys, and bound partition size deliberately
  • Apply query-first modelling: enumerate queries, then build one table per query
  • Denormalise correctly, and maintain the copies you create
  • Use collections, UDTs and TTL, and state the cost of each
  • Choose a consistency level per statement, and apply the R + W > RF arithmetic
  • Explain last-write-wins conflict resolution and the risk of clock skew
  • Use lightweight transactions, and state what they cost
  • Explain why a multi-partition batch is usually a mistake
  • Configure driver retry, speculative execution and token-aware routing
  • Explain LSM storage, SSTables and the read path
  • Choose a compaction strategy with a reason
  • Diagnose tombstones, and explain why a queue is an anti-pattern
  • Read a trace and act on what it shows
  • Configure replication across racks and datacentres
  • Run repair, understand hinted handoff, and replace a node
  • Implement authentication, authorisation and TLS
  • Produce a deployment, capacity and cost checklist

What each level covers

5 levels · 7 lessons

  1. Beginner - Foundations

    The ring and CQL; then the query-first discipline that is the whole of Cassandra data modelling.

    2 lessons 17 min of reading

    Start with The Ring, CQL, Keyspaces and Key Design →
  2. Intermediate - Application Behaviour

    Consistency as a per-statement choice, last-write-wins, and the driver behaviour that decides what your users see.

    1 lesson 7 min of reading

    Start with Consistency Levels, Timestamps, LWT and Batches →
  3. Advanced - Performance and Reliability

    The LSM engine, compaction and the tombstone; then replication, repair and node replacement.

    2 lessons 18 min of reading

    Start with LSM Storage, Compaction, Tombstones and Tracing →
  4. Expert - Security and Production Architecture

    Roles and TLS, the metrics that matter, capacity planning and the rolling upgrade.

    1 lesson 10 min of reading

    Start with Authentication, Authorisation, TLS and Operations →
  5. Capstone

    One global event feed, defended on bounded partitions, measured consistency and a survived node loss.

    1 lesson 7 min of reading

    Start with Capstone - Global Event Feed →

Guides and articles

Longer reading about this subject, written alongside the course.

Course guide How to work through this course Why three nodes from day one, the two experiments that matter, what to unlearn, and what to skip. 4 min read

Before you start

  • Apache Cassandra 5 or later, as a three-node cluster
  • cqlsh, and Docker Compose or ccm
  • One programming language with the DataStax driver
  • 8 GB of RAM or more for the cluster laboratories
  • The programme's shared foundations

Common questions

What does the Apache Cassandra: Query-First Modeling and Tunable Consistency course cover?
It is 5 levels and 7 lessons: Beginner - Foundations; Intermediate - Application Behaviour; Advanced - Performance and Reliability; Expert - Security and Production Architecture; Capstone. Each level ends with a quiz, and the last one is an exam over the whole course.
How long does it take?
About 59 minutes of reading and exercises - roughly 1 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
What do I need to know first?
Apache Cassandra 5 or later, as a three-node cluster. cqlsh, and Docker Compose or ccm. One programming language with the DataStax driver. 8 GB of RAM or more for the cluster laboratories. The programme's shared foundations.
Is it free?
Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
What will I be able to do afterwards?
Explain the ring, token ranges, the coordinator and virtual nodes. Use CQL fluently, and name precisely where it differs from SQL. Design partition and clustering keys, and bound partition size deliberately. Apply query-first modelling: enumerate queries, then build one table per query. Denormalise correctly, and maintain the copies you create. Use collections, UDTs and TTL, and state the cost of each. Choose a consistency level per statement, and apply the R + W > RF arithmetic. Explain last-write-wins conflict resolution and the risk of clock skew. Use lightweight transactions, and state what they cost. Explain why a multi-partition batch is usually a mistake. Configure driver retry, speculative execution and token-aware routing. Explain LSM storage, SSTables and the read path. Choose a compaction strategy with a reason. Diagnose tombstones, and explain why a queue is an anti-pattern. Read a trace and act on what it shows. Configure replication across racks and datacentres. Run repair, understand hinted handoff, and replace a node. Implement authentication, authorisation and TLS. Produce a deployment, capacity and cost checklist.