---
title: Types of Databases Explained: 8 Kinds With Examples
url: https://www.masaischool.com/resources/types-of-databases-explained
description: Types of databases: relational, document, key-value, wide-column, graph, time-series, vector and in-memory, with a real product for each and a decision table.
updated: 2026-11-17
publisher: Masai (https://www.masaischool.com)
---

# Types of Databases: Relational, Document, Key-Value, Graph, Vector and More, With Real Examples

> **Short answer**
>
> The main types of databases are relational (PostgreSQL, MySQL), document (MongoDB), key-value (Redis), wide-column (Apache Cassandra), graph (Neo4j), time-series (InfluxDB) and vector (Pinecone, or pgvector inside PostgreSQL). Each stores data in a different shape for a different job. Most apps start with one relational database and add another type only when a measured need appears.

Four related searches (types of databases, database types, databases types and types of database) bring readers here. Textbooks sometimes list hierarchical and network models; this page covers the kinds you will meet in jobs and projects today.

Product facts were read from DB-Engines (November 2026), the Stack Overflow Developer Survey 2026 and each product's own documentation on 11 November 2026. Usage figures describe survey respondents, not all developers.

## The eight types at a glance

| Type | Data is stored as | Real product | Good for |
|---|---|---|---|
| Relational | Tables of rows and columns, linked by keys | PostgreSQL, MySQL | Orders, payments, student records: anything with clear relationships |
| Document | JSON-like documents in collections | MongoDB | Catalogues, profiles, content whose fields vary |
| Key-value | A key that points to a value, like a giant dictionary | Redis, Amazon DynamoDB | Sessions, counters, caches, lookups by ID |
| Wide-column | Rows grouped by a partition key, spread over many servers | Apache Cassandra | Very large data across many machines |
| Graph | Nodes and the relationships between them | Neo4j | Social links, recommendations, route and fraud patterns |
| Time-series | Measurements stamped with a time | InfluxDB | Metrics, monitoring, sensor readings |
| Vector | Lists of numbers (embeddings) searched by similarity | Pinecone, Qdrant, pgvector | Semantic search and RAG for LLM apps |
| In-memory | Data held in RAM for speed | Redis | Caching, leaderboards, rate limits |

In-memory describes where data lives, not its shape, so it overlaps with the others. Redis is both key-value and in-memory. Its documentation calls it an in-memory data structure store, and the name stands for Remote Dictionary Server.

Document, key-value, wide-column and graph databases are usually grouped as NoSQL. Cassandra's documentation describes NoSQL databases as non-relational and largely distributed. The groups blur in practice: DB-Engines lists MongoDB as a document store that also offers key-value, time-series and vector models, and lists PostgreSQL as relational with document, graph and vector features.

## The same fact in four shapes

A runnable way to feel the difference is to store one user, Asha from Pune, four ways. The relational version needs a table first. The key-value version is a dictionary lookup. The document version nests data. The graph version answers a question about connections.import json import sqlite3 # Relational: rows in a table, one fixed set of columns db = sqlite3.connect(":memory:") db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, city TEXT)") db.execute("INSERT INTO users VALUES (7, 'Asha', 'Pune')") print(db.execute("SELECT name FROM users WHERE city = 'Pune'").fetchall()) # Key-value: one key, one value, no query language cache = {"session:7": "Asha"} print(cache["session:7"]) # Document: nested JSON, fields can differ between documents doc = {"_id": 7, "name": "Asha", "skills": ["python", "sql"], "address": {"city": "Pune"}} print(json.dumps(doc["address"])) # Graph: nodes and edges, ask "who is two hops away?" follows = {"Asha": ["Ravi"], "Ravi": ["Meera"], "Meera": []} two_hops = {c for friend in follows["Asha"] for c in follows[friend]} print(sorted(two_hops))

Output: [('Asha',)], then Asha, then {"city": "Pune"}, then ['Meera']. Meera is two hops from Asha through Ravi. In a graph database that is one query; in a relational database it is a join per hop.

## Which products people actually use

| Product | Type | Stack Overflow 2026 (n = 12,061) | DB-Engines score, Nov 2026 |
|---|---|---|---|
| PostgreSQL | Relational | 57.9% | 689.69 (rank 4) |
| MySQL | Relational | 35.1% | 823.23 (rank 2) |
| Redis | Key-value, in-memory | 28.3% | 163.29 (rank 8) |
| MongoDB | Document | 19.0% | 366.14 (rank 5) |
| InfluxDB | Time-series | 3.6% | 20.45 (top time-series) |
| Neo4j | Graph | 2.8% | 47.55 (top graph) |
| Apache Cassandra | Wide-column | 2.5% | 98.41 (top wide-column) |
| Pinecone | Vector | not listed | 9.33 (top dedicated vector) |

The survey column is the share of respondents who had done extensive work with the product in the past year. DB-Engines publishes a monthly popularity score for 442 systems, and Oracle led it in November 2026 at 1096.15. Treat the score as a popularity index, not a count of users. The pattern is clear in both lists: relational databases lead, and every other type is a specialist tool.

Elasticsearch ranked first in DB-Engines' vector DBMS list in November 2026, ahead of OpenSearch and Couchbase, but DB-Engines classes it mainly as a search engine. Among systems built only for vectors, Pinecone, Qdrant, Milvus and Weaviate led.

## Vector databases, honestly

AI apps turn text into embeddings: lists of numbers where similar meanings sit close together. A vector database stores those lists and finds the nearest ones to a query. This toy does the core step with three numbers per document, using cosine similarity. A real system uses hundreds or thousands of numbers and an index to avoid comparing every row.import math # Toy 3-dimensional "embeddings". Real models output hundreds or thousands of numbers. docs = { "cat care tips": [0.9, 0.1, 0.0], "dog training": [0.8, 0.3, 0.1], "income tax slabs": [0.0, 0.1, 0.95], } def cosine(a, b): dot = sum(x * y for x, y in zip(a, b)) return dot / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b))) query = [0.85, 0.2, 0.05] # pretend this is the embedding of "pet advice" ranked = sorted(docs, key=lambda name: cosine(query, docs[name]), reverse=True) for name in ranked: print(f"{name}: {cosine(query, docs[name]):.3f}")

Output: cat care tips: 0.991, dog training: 0.990, income tax slabs: 0.081. The query about pets lands near the two pet documents and far from the tax one.

You do not always need a separate product. pgvector is an open-source extension that adds vector search to Postgres. Its README says it supports exact and approximate nearest-neighbour search, does exact search by default with perfect recall, and lets you add an HNSW or IVFFlat index to trade some recall for speed. It comes preinstalled with Postgres.app and many hosted providers.CREATE EXTENSION vector; CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3)); INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'); SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;

For a student RAG project with a few thousand documents, pgvector inside a Postgres you already run is a reasonable first choice. A dedicated vector database earns its place when scale or specialised features demand it. Try it in the [free RAG chatbot guide](https://www.masaischool.com/resources/build/rag-chatbot-free-gemini-streamlit) and compare hosting in [free backends and databases](https://www.masaischool.com/resources/tools/free-backend-and-database-for-ai-apps).

## Which type should you pick?

| If your data or need is... | Start with | Why |
|---|---|---|
| Tables with clear relationships: users, orders, marks | PostgreSQL or MySQL | Joins, constraints and transactions are built in. See [SQL vs MySQL](https://www.masaischool.com/resources/sql-vs-mysql-difference). |
| Learning SQL with zero setup | SQLite | A single file and no server. |
| Nested JSON that changes often, in a JavaScript project | MongoDB | One document holds the whole object. See [what is MongoDB](https://www.masaischool.com/resources/what-is-mongodb-explained). |
| Fast lookups, sessions or a cache | Redis | Data sits in memory, so reads are quick. |
| Questions about connections: friends of friends | Neo4j | Relationships are stored as first-class data. |
| Metrics and sensor readings over time | InfluxDB | Built for timestamped data. |
| Semantic search for an LLM app | pgvector first | No second system to run. |
| Huge data spread over many servers | Cassandra | It scales out by adding nodes. |

The safe rule: start with one relational database and add a second type only when you can name the query it makes faster or the data it stores better. For hosted free tiers see [free backends and databases](https://www.masaischool.com/resources/tools/free-backend-and-database-for-ai-apps), then see how databases fit with the rest of the [tech stack](https://www.masaischool.com/resources/tech-stack-explained).

Masai's longer guides: [Types of Databases](https://www.masaischool.com/blog/types-of-databases/) and [Types of NoSQL Databases](https://www.masaischool.com/blog/types-of-nosql-databases/).

## Frequently asked questions

### What are the main types of databases?

Relational, document, key-value, wide-column, graph, time-series, vector and in-memory. Relational databases such as PostgreSQL and MySQL are the default for most apps. The others solve specific problems: nested data, caching, huge scale, connected data, time-based readings or similarity search for AI.

### What is the difference between SQL and NoSQL databases?

SQL databases are relational: tables with fixed columns, queried with SQL. NoSQL databases are non-relational and include document, key-value, wide-column and graph stores. The line is blurry, since MongoDB supports multi-document transactions and DB-Engines lists PostgreSQL with a document model too.

### Is MongoDB SQL or NoSQL?

NoSQL, specifically a document database. It stores JSON-like documents in collections and is queried with query documents rather than SQL, though it supports multi-document ACID transactions. See the MongoDB explainer on this site for commands, indexes and the free Atlas cluster limits.

### Is Redis a database?

Yes, though it is often used as a cache. Redis keeps data in memory as keys mapped to values and richer structures such as hashes, which makes reads very fast. Its own documentation calls it an in-memory data structure store, and the name means Remote Dictionary Server.

### Do I need a vector database for RAG?

Not at first. The pgvector extension adds vector search to PostgreSQL and does exact nearest-neighbour search by default, which is fine for small collections. Move to a dedicated vector database such as Pinecone, Qdrant or Milvus only when your scale or features require it.

### Which database is the most popular?

By usage, PostgreSQL: 57.9% of respondents in the Stack Overflow Developer Survey 2026 said they had used it extensively. By DB-Engines popularity score in November 2026, Oracle ranked first, then MySQL, Microsoft SQL Server and PostgreSQL. The two lists measure different things.

## Sources checked

- [442 systems, scores and models, Nov 2026](https://db-engines.com/en/ranking)
- [key-value ranking](https://db-engines.com/en/ranking/key-value+store)
- [vector DBMS ranking](https://db-engines.com/en/ranking/vector+dbms)
- [graph ranking](https://db-engines.com/en/ranking/graph+dbms)
- [time-series ranking](https://db-engines.com/en/ranking/time+series+dbms)
- [wide-column ranking](https://db-engines.com/en/ranking/wide+column+store)
- [usage shares, n = 12,061](https://survey.stackoverflow.co/2026/technology/data/databases)
- [pgvector README](https://github.com/pgvector/pgvector)
- [Redis in-memory data structure store](https://redis.io/docs/latest/develop/get-started/data-store/)
- [Cassandra is distributed NoSQL](https://cassandra.apache.org/_/cassandra-basics.html)
- [Neo4j native graph database](https://neo4j.com/docs/getting-started/whats-neo4j/)
