Cassandra and Neo4j (NoSQL families) Tutorial
Learn Cassandra and Neo4j (NoSQL families) step by step: 30 lessons in 10 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Wide-Column and Graph Databases
The Two Architectures
- Cassandra architecture in one picture See how Cassandra spreads data over a peer-to-peer ring of nodes, how token ranges decide ownership and how the replication factor keeps copies.
- Neo4j and the property graph model Learn the property graph model used by Neo4j: nodes, relationships, labels and properties, plus why index-free adjacency makes traversals cheap.
Cassandra Data Model
- CQL: keyspaces, tables and basic queries Learn CQL, the Cassandra Query Language: create keyspaces and tables, then INSERT, SELECT, UPDATE and DELETE, and see how it differs from SQL.
- Partition keys and clustering keys Understand the anatomy of a Cassandra primary key: the partition key that picks the node and the clustering columns that sort rows inside a partition.
- Query-first data modeling Learn query-first modeling for Cassandra: list your queries, build one table per query, duplicate data on purpose, and keep the copies in step.
- Data types, collections and UDTs Learn the Cassandra types you will use daily: uuid and timeuuid, timestamp, decimal, list, set, map, frozen values, user-defined types and counters.
- Time-series and bucketing patterns Model sensor and event data in Cassandra: time buckets that cap partition size, clustering order DESC, TTL expiry and how to read across buckets.
How Cassandra Works Inside
- The write path: commit log, memtable, SSTable See why Cassandra writes are fast: append to a commit log, update an in-memory memtable, flush immutable SSTables. Includes a runnable LSM stand-in.
- The read path, bloom filters and compaction Follow a Cassandra read through the memtable and SSTables, learn how bloom filters skip files, and compare STCS, LCS and TWCS compaction strategies.
- Replication and tunable consistency Understand replication factor and Cassandra consistency levels (ONE, QUORUM, ALL), the R+W>N rule, hinted handoff, read repair and anti-entropy repair.
- Deletes, TTL and tombstones Learn how Cassandra deletes data with tombstones, what gc_grace_seconds protects, why zombie data returns, and how to avoid tombstone-heavy reads.
Cassandra in Practice
- Lightweight transactions, batches and counters Learn when Cassandra's IF NOT EXISTS (lightweight transactions) is worth its cost, how logged and unlogged batches really work, and where counters bite.
- Secondary indexes, SAI and materialized views Why Cassandra secondary indexes are risky, what Storage-Attached Indexes change, why materialized views are experimental, and when to denormalize instead.
- Multi-datacenter setups and security Configure Cassandra across datacenters with NetworkTopologyStrategy and LOCAL_QUORUM, then lock it down with roles, permissions, TLS and audit logging.
- Drivers, nodetool and production pitfalls Connect to Cassandra with the Python and Java drivers, use prepared statements and token-aware routing, read nodetool output and avoid common anti-patterns.
Cypher and Graph Modeling
- Cypher: MATCH, CREATE and patterns Learn Cypher, Neo4j's query language: draw patterns with ASCII art, create nodes and relationships, match them, filter with WHERE and return properties.
- Cypher: MERGE, SET, DELETE and constraints Change a Neo4j graph safely with Cypher: idempotent MERGE, SET and REMOVE, DELETE versus DETACH DELETE, plus uniqueness constraints and indexes.
- Paths, aggregation and WITH Learn Cypher variable-length paths, shortestPath, count and collect, WITH pipelines, OPTIONAL MATCH, ORDER BY and LIMIT, with runnable Python stand-ins.
- Graph data modeling Learn how to model data as a graph: when to use nodes, properties or relationships, how to name types and pick directions, and how to avoid supernodes.
Graph Algorithms and Applications
- Query performance: indexes, EXPLAIN and PROFILE Speed up Cypher queries: range and text indexes, reading EXPLAIN and PROFILE plans, counting db hits, avoiding cartesian products and using parameters.
- Graph algorithms: PageRank, communities, shortest paths See how Neo4j's Graph Data Science library runs PageRank, community detection, betweenness and Dijkstra, and build each idea yourself in Python.
- Recommendations and fraud detection with graphs Use graph patterns for collaborative filtering, friend-of-friend suggestions and fraud rings built on shared identifiers, with Cypher and Python stand-ins.
Projects
- Project: a social network on a graph Model users, follows and posts in Neo4j, then write the Cypher for a feed, mutual friends and follow suggestions, with JavaScript stand-ins you can run.
- Project: an event and order store on Cassandra Design a Cassandra event and order store from its queries: bucketed events, order history by user, and consistency choices, with Python stand-ins.
- Project: a knowledge graph Build a small knowledge graph: entities, typed relationships, a CSV import with LOAD CSV and MERGE, and path queries that explain how things connect.
Practice
- Practice exercises with solutions Eight hands-on exercises for CQL and Cypher: data modeling, query rules, consistency math, friend suggestions and MERGE, with worked solutions.
- Cassandra, Neo4j, or something else? A practical decision guide for Cassandra, Neo4j and relational databases: workloads, scaling, hybrid designs, common mistakes and migrating from SQL.
Interviews and Cheat Sheet
- Interview questions and answers Prepare for Cassandra and Neo4j interviews: CAP, partitioning, consistency, compaction, tombstones, Cypher patterns and modeling, with model answers.
- Cassandra and Neo4j cheat sheet A one-page reference for CQL and Cypher syntax, Cassandra consistency levels, modeling rules and common pitfalls, with a searchable stand-in.