Lesson 1.2 · Reading time: ~15 min
There are many types of databases, each optimized for a specific kind of data, query pattern, or scalability requirement. In this lesson you'll learn the main database models — relational, key-value, document, wide-column, graph, time-series, and columnar — with their key differences, typical use cases, and examples of real systems.
In the previous lesson, we introduced the general idea of a database and a DBMS. In practice, not all databases are built the same way. Different database types are optimized for different kinds of data, query patterns, scalability requirements, and consistency needs.
We will also take a closer look at relational databases, because they will remain our main focus throughout this course.
No single database design is perfect for every application.
For example:
Because different systems solve different problems, several database models have emerged over time.
Here is a quick comparison before we examine each type in more detail:
| Type | Data Model | Strengths | Common Use Cases | Examples |
|---|---|---|---|---|
| Relational | Tables with rows and columns | Strong consistency, SQL, joins, structured data | Banking, ERP, CRM, e-commerce, reporting | PostgreSQL, MySQL, MariaDB, SQLite, Oracle |
| Key-Value | Key paired with value | Very fast lookups, simple scaling | Caching, sessions, feature flags, shopping carts | Redis, Amazon DynamoDB, Riak |
| Document | JSON-like documents | Flexible schema, nested data | Content management, user profiles, catalogs, web apps | MongoDB, Couchbase, Firestore |
| Wide-Column | Rows with flexible columns grouped by families | High write throughput, horizontal scaling | Event logging, IoT, large-scale distributed workloads | Apache Cassandra, HBase, ScyllaDB |
| Graph | Nodes and edges | Relationship-heavy queries | Social networks, fraud detection, recommendation engines | Neo4j, Amazon Neptune, ArangoDB |
| Time-Series | Time-stamped records | Efficient ingestion and aggregation over time | Monitoring, metrics, sensors, financial ticks | InfluxDB, TimescaleDB, OpenTSDB |
| Columnar Analytical | Data stored by column instead of by row | Fast analytical scans and aggregation | BI, dashboards, warehousing, OLAP | ClickHouse, DuckDB, Amazon Redshift, BigQuery |
| In-Memory | Data stored primarily in RAM | Extremely low latency | Caching, leaderboards, real-time counters | Redis, Memcached, SAP HANA |
Relational databases store data in tables made of rows and columns. Tables can be connected to each other through relationships, usually using primary keys and foreign keys.
This model is especially good when data is well structured and when correctness, consistency, and complex querying are important.
1. Structured schema
Relational databases usually require a clearly defined schema. Before storing data, you define tables, columns, data types, constraints, and relationships.
This makes the structure predictable and easier to validate.
2. Relationships between tables
A major strength of relational systems is the ability to model relationships explicitly.
For example:
customers table can be related to an orders table.orders table can be related to an order_items table.This makes relational databases well suited for business systems where entities are interconnected.
3. SQL support
Relational databases are commonly queried using SQL (Structured Query Language). SQL provides a standard way to filter, join, aggregate, sort, and modify structured data.
4. ACID transactions
Relational databases are well known for supporting ACID properties:
These properties are critical in systems such as banking, billing, reservations, and inventory control.
5. Data integrity constraints
Relational databases can enforce rules directly in the database layer, for example:
NOT NULL constraintsThese features help prevent invalid or inconsistent data.
6. Powerful joins and reporting
Relational databases excel when you need to combine information from multiple tables. This is one reason they remain central to reporting, analytics, finance, operations, and many transactional systems.
7. Normalization and reduced redundancy
Relational design often uses normalization, which means organizing data into related tables to reduce duplication and improve consistency.
For example, customer information can be stored once in a customers table instead of being repeated in every order record.
Relational databases are usually the best choice when:
Key-value databases store data as a simple pair: a key and its associated value.
The key works like a unique identifier, and the database retrieves the value directly from that key. This model is very simple and very fast.
Document databases store data as documents, usually in a JSON-like format. Each document can contain fields, arrays, and nested objects.
Unlike relational databases, not every document must have exactly the same structure.
Wide-column databases, sometimes called column-family databases, store data in rows, but each row can have a very large and flexible set of columns. They are designed for distribution across many servers and for high write throughput.
A columnar database stores values of the same column together on disk instead of storing a full row together. This is different from a wide-column database.
Columnar storage is especially efficient for analytical queries that read a few columns from a very large dataset.
Graph databases are designed for data where relationships are the most important part of the model. They store nodes (entities) and edges (relationships).
Time-series databases are specialized for data points associated with time. They are optimized for high ingestion rates, retention policies, compression, and time-based aggregation.
In-memory databases store most or all data in RAM rather than on disk. This makes them extremely fast, though memory is more expensive than disk storage.
Some in-memory databases are used only as temporary caches, while others can also persist data to disk.
When selecting a database, ask questions like these:
In many real systems, organizations use more than one database type. For example:
This is often called polyglot persistence.
The main differences between database types usually involve:
Key Takeaways:
Relational databases use a fixed table-based schema, enforce ACID transactions, and are queried with SQL. NoSQL databases is an umbrella term covering key-value, document, wide-column, and graph models — they trade some consistency guarantees for schema flexibility or horizontal scalability. Neither is universally better; the right choice depends on your data and workload.
Use a document database when your data has a naturally nested, variable structure (e.g. product catalogs with different attributes per product) and you rarely need to join across collections. Use a relational database when data is structured, entities are interrelated, and you need reliable transactions and complex multi-table queries.
Yes — this is called polyglot persistence. It is common in production systems: for example, PostgreSQL for transactional data, Redis for caching, and ClickHouse for analytics. Each database type is used where it performs best.
Start from the workload and constraints: data structure, consistency needs, query patterns, latency targets, and scale. For example, choose a relational database for ACID-heavy transactional systems, a document database for flexible JSON-like records, and a time-series database for timestamped metrics with retention policies.
Every model is a trade-off. Relational databases provide strong consistency, joins, and mature SQL tooling, but schema changes can be stricter at scale. NoSQL models often provide better flexibility or horizontal scaling, but they may limit joins or require careful consistency design.
Yes. This is polyglot persistence: using multiple databases, each for the workload it handles best. A common pattern is PostgreSQL for core transactions, Redis for caching, and ClickHouse (or another columnar system) for analytics.