Types of Databases
There is no single "best" database. Different applications store different shapes of data and ask different questions, so over the years several families of databases have appeared, each optimized for a particular job.
This tutorial walks through the main types you will meet today, shows what data looks like in each, names popular products, and ends with a simple guide for choosing one.
1. Overview
Databases are usually grouped by their data model: the way they organize data and relationships. The table gives a quick map; each type is explained below.
| Type | Stores data as | Popular examples | Typical use |
|---|---|---|---|
| Relational | Tables of rows and columns | PostgreSQL, MySQL, Oracle, SQL Server | Business systems, finance, ERP |
| Document | JSON-like documents | MongoDB, Couchbase, Amazon DocumentDB | Web and mobile apps, catalogues, content |
| Key-value | A key mapped to a value | Redis, Amazon DynamoDB, etcd | Caching, sessions, counters |
| Wide-column | Rows with flexible column families | Apache Cassandra, ScyllaDB, HBase | Huge write-heavy workloads |
| Graph | Nodes and relationships | Neo4j, Amazon Neptune | Social networks, recommendations, fraud |
| Time-series | Timestamped measurements | InfluxDB, TimescaleDB, MongoDB time series collections | IoT, metrics, monitoring |
| Search | Inverted text indexes | Elasticsearch, OpenSearch, Atlas Search | Full-text search, log analysis |
| Vector | Numeric embeddings | Pinecone, Milvus, Atlas Vector Search, pgvector | AI semantic search, RAG |
2. Relational Databases
Relational databases store data in tables. Every row in a table has the same columns, and tables are linked through keys: an orders row holds the customer_id of the customer who placed it. You query them with SQL, and a JOIN combines related tables at query time.
SELECT c.name, o.total
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id
WHERE o.status = 'SHIPPED';
- Strengths: strict schemas, strong consistency, mature ACID transactions, powerful ad-hoc queries.
- Trade-offs: schema changes need planning, and scaling writes beyond one server is harder.
A newer group called distributed SQL (sometimes "NewSQL"), with products such as CockroachDB, YugabyteDB and Google Spanner, keeps the relational model and SQL but spreads data across many servers.
3. Document Databases
Document databases store each record as a document, usually JSON or a binary form of it such as MongoDB's BSON. A document can contain nested objects and arrays, so data that belongs together is stored together, and documents in the same collection do not need identical fields.
{
_id: "C-1",
name: "Aditi Rao",
address: { city: "Pune", pin: "411001" },
orders: [
{ orderId: 5001, total: 919, status: "SHIPPED" }
]
}
- Strengths: the data maps directly to objects in code, the schema can evolve, and they scale out horizontally.
- Trade-offs: good results depend on designing documents around how the application reads data.
MongoDB, the subject of this tutorial, is the most widely used document database.
4. Key-Value Databases
The simplest model: each value is stored and fetched by a unique key, like a giant distributed hash map. The database usually does not look inside the value.
SET session:9f2a "{\"userId\": 42, \"cart\": 3}" EX 1800
GET session:9f2a
INCR page:home:views
Key-value stores are extremely fast, which makes them ideal for caches, user sessions, rate-limit counters and feature flags. They are a poor fit when you need to search by anything other than the key.
5. Wide-Column Databases
Wide-column stores organize data into rows and column families, but each row can have different columns and millions of them. Data is partitioned across many nodes by a partition key and written very efficiently.
Apache Cassandra and ScyllaDB are used for workloads such as messaging histories, activity feeds and telemetry, where huge volumes of writes must be spread over many servers across data centres. Queries must be designed around the partition key, and ad-hoc querying is limited.
6. Graph Databases
Graph databases store nodes (things) and relationships (how things connect), and both can have properties. Following a relationship is cheap, so questions like "friends of friends who bought this book" are fast even many hops deep.
MATCH (me:Person {name: "Aditi"})-[:FRIEND]->(:Person)-[:FRIEND]->(fof:Person)
WHERE NOT (me)-[:FRIEND]->(fof) AND me <> fof
RETURN DISTINCT fof.name
Typical uses include recommendations, fraud detection, network and IT dependency maps, and knowledge graphs.
7. Time-Series Databases
Time-series data is a stream of measurements with a timestamp: CPU usage every 10 seconds, temperature readings, stock prices. Time-series databases compress such data heavily, store it in time order and make range queries and aggregations over time windows fast.
Dedicated products include InfluxDB and TimescaleDB, and MongoDB offers time series collections that bring the same storage optimizations into a general-purpose database.
8. Search Engines
Search engines build an inverted index that maps each word to the documents containing it. They rank results by relevance, handle typos and synonyms, and support facets and highlighting. Elasticsearch and OpenSearch are common choices, and MongoDB Atlas includes Atlas Search so you can search without copying data to a separate system.
9. Vector Databases
AI models turn text, images or audio into embeddings: lists of numbers where similar meanings are close together. Vector databases index these embeddings and quickly find the nearest ones, which powers semantic search, recommendations and retrieval-augmented generation (RAG) for chatbots.
Vector search is offered both by specialized products and as a feature of general databases, for example Atlas Vector Search in MongoDB Atlas and the pgvector extension for PostgreSQL.
10. Other Types Worth Knowing
- In-memory databases keep the whole data set in RAM for microsecond responses, often with persistence to disk (Redis, Memcached as a pure cache).
- Embedded databases run inside the application process with no server at all (SQLite, H2, RocksDB). Mobile apps and browsers use them heavily.
- Data warehouses are column-oriented systems built for analytics over very large data sets (Snowflake, BigQuery, Amazon Redshift).
- Multi-model databases support more than one model in a single product. MongoDB, for example, combines documents with time series, search and vector capabilities.
- Hierarchical and network databases are historical models from the 1960s and 1970s that organized records as trees or linked sets; some still run in mainframe systems.
11. How to Choose
| If your main need is… | Consider |
|---|---|
| Strict structure, complex joins and reporting | Relational |
| Flexible, nested data that maps to application objects | Document |
| Very fast lookups by key, caching, sessions | Key-value |
| Massive write volume spread across many servers | Wide-column |
| Deeply connected data and relationship queries | Graph |
| Metrics, sensor data and events over time | Time-series |
| Relevance-ranked text search | Search engine |
| Similarity search for AI applications | Vector search |
Large systems often use several databases side by side, each for the job it does best. This approach is called polyglot persistence. Before adding another database, though, check whether your main one already covers the need: every extra system adds operations, security and data-syncing work.
12. Summary
- Databases are grouped by data model: relational, document, key-value, wide-column, graph, time-series, search and vector are the main families today.
- Relational databases use tables and SQL; the other families are usually grouped under the name NoSQL.
- Each type is optimized for particular access patterns, so choose based on how your application reads and writes data.
- MongoDB is a document database that also supports time series, full-text search and vector search.