NoSQL databases

Beyond tables · Part of Databases

Key idea

Practice

7 questions · about 4 min

Explained step by step

NoSQL

NoSQL is a broad family: any database that doesn't use SQL as its main language. They're also called non-relational. Unlike SQL, you don't need to define a schema first: each record can have different fields. It's like a shoebox where you keep whatever comes, instead of a form with fixed boxes. They usually follow the BASE model, which puts being available ahead of always being up to date.

Document database

A document database stores each piece of data as a document, similar to JSON: a user with their name, email and 3 addresses, all together. It's general-purpose, intuitive and flexible, and scales horizontally easily. Since it has no schema, each document can have different fields, which is both an advantage and a downside: nothing stops you from storing data wrongly. It's like a folder per customer with all their papers inside. Examples: MongoDB and CouchDB.

Key-value store

A key-value database is one of the simplest: it stores pairs of 2 items, a key and its value. You ask for the key and get the value, very fast. It's ideal for sessions, caches and direct lookups, and handles huge traffic. In exchange, it only does the basics: you can't filter by value or run complex queries. It's like a coat check: with number 42 you get your coat, but you can't ask for 'all the red coats'. Examples: Redis, Memcached and DynamoDB.

Graph database

A graph database stores data as nodes (things) and edges (relationships between things), with properties on each. Relationships are stored directly, so questions like 'friends of my friends' are answered in 1 operation, without joining tables. It's like a subway map: stations are nodes and tracks are edges. It's used for social networks, recommendations and fraud detection. It's more complex and has no standard language. Example: Neo4j.

Time-series database

A time-series database is optimized for data with a date and time: measurements arriving one after another. It inserts and reads very fast, and stores data efficiently. It's like a thermometer's diary noting the temperature every minute. It's used for sensors (IoT), metrics, app monitoring and financial trends. A sensor measuring every 1 second produces 86,400 data points a day. Examples: InfluxDB and TimescaleDB.

Wide column

A wide-column database stores data in column families instead of fixed rows and columns, and doesn't require a schema. It scales enormously: it handles petabytes and is ideal for real-time big data. In exchange, it's expensive and writes can take longer. It's like a card file where each card only has the boxes it uses. It's used for business analytics and attribute-based data. Examples: Cassandra and HBase.

Multi-model

Each NoSQL type solves a different problem, and multi-model databases combine several (document, graph, key-value, relational) in one system. They're flexible and suit complex projects, but they're more complicated and less mature. It's like a Swiss army knife: it has many tools, but none is as good as the tool on its own. Multi-model examples: ArangoDB and Azure Cosmos DB.

Terms in this lesson

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.

Key idea

Beyond tables