In the previous lesson, we introduced the general idea of a database and a DBMS. In practice, however, 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.
In this lesson, we will look at the most common database types, their key differences, typical use cases, and real-world examples. 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:
In the next lesson, we will go deeper into the internal structure of relational databases, including tables, rows, columns, keys, and integrity.