NoSQL for Data Engineers
This topic is not about choosing a database for a service. SQL versus NoSQL, CAP, and the database families are covered in system analysis. This is the view of a data engineer handed a NoSQL database as a source: how it stores data, what you can read from it without hurting production, how changes reach the warehouse, and what a document becomes when you put it into tables.
The main difference from a relational source is that the data model is built for the application's queries, not for analytics. In Cassandra a table answers one query, in MongoDB an order is stored together with its items, in Redis ready-made values sit under keys. Joins, arbitrary filters, and a consistent snapshot of the whole database are usually absent. So an extract is designed around the specific database, and the warehouse schema is reconstructed from the documents.
Versions in the text: Cassandra and Redis without a version where behaviour has not changed; for MongoDB the version that introduced a feature is named.
The three families from the pipeline's side
| Family | Examples | How data is laid out | How it is extracted | Main trap |
|---|---|---|---|---|
| Wide-column | Cassandra, HBase, Bigtable | Rows by partition key or row key, sorted within | Scans by token or key ranges, CDC | Consistency is chosen per request; a delete is a marker |
| Document | MongoDB | JSON-like documents with nested arrays | Change streams, collection export | Every document has its own schema; arrays multiply rows |
| Key-value | Redis, DynamoDB | A value per key; scanning is expensive | The database's own export, a change stream | The cache is mistaken for the source of truth |
Graph databases rarely enter analytical pipelines and are not covered here.
Topic map
- Wide-column — query-first modelling in Cassandra, the partition key and clustering columns, tombstones and
gc_grace_seconds, consistency levels and what an extract sees. - Document stores — embedding and references in MongoDB, flattening arrays into child tables, change streams as CDC, the resume token and the oplog window.
- Key-value and caches — why Redis is not the source of truth, RDB and AOF, row keys in HBase and Bigtable and hot regions, DynamoDB export.
- NoSQL in the lake — a raw JSON layer, schema drift, schema inference and corrupt records in Spark, safe exports and type preservation.
Common traps
| Mistake | Consequence |
|---|---|
Extracting Cassandra with ALLOW FILTERING from the production cluster | A full scan of every partition, latency for the application |
Reading at ONE when writes went at ONE | The extract misses acknowledged writes |
Not running repair for longer than gc_grace_seconds | Deleted rows come back, and counts drift |
| Flattening an order with an items array into one table and summing the order total | Revenue is multiplied by the item count |
| Storing the resume token but not watching the oplog window | The stream cannot resume, and a new initial snapshot is needed |
| Treating Redis as the system of record | A crash loses up to a second of writes with AOF and minutes with RDB snapshots |
| Loading JSON straight into typed columns | The first type change of a field fails the load or silently nulls values |
Interview relevance
The interview checks whether a candidate understands that a NoSQL source breaks the usual extract techniques. A strong answer names the mechanism: "the extract came up short because the application writes at ONE with RF 3, and we also read at ONE. The write and read replica sets did not overlap."
Typical checks:
- Why a Cassandra table is built for a query, and what
ALLOW FILTERINGdoes. - Tombstones,
gc_grace_seconds, and resurrected rows. - Consistency levels and the W + R > RF rule.
- Embedding versus references, and how to flatten an array without double counting.
- Change streams as CDC: the resume token, the oplog,
updateLookup, and pre-images. - A monotonic row key and a hot region.
- Redis as a cache, not a source.
- Schema drift and a raw JSON layer.
Common wrong answer: "We will extract the Cassandra table with SELECT * … ALLOW FILTERING, there is not much data." ALLOW FILTERING explicitly permits a full scan of every partition, and its cost grows with the table, not with the result. A bulk extract is a throttled scan by token ranges, preferably from a separate analytics datacenter, or the change stream instead.