Lesson 3 of 2230 min read

Types of Databases: Relational, NoSQL, Hierarchical, Network and Cloud

Explore all major database types, understand when each is used, and learn why relational databases are the foundation of SQL learning.

Types of Databases: Relational, NoSQL, Hierarchical, Network and Cloud

Not all data is the same, and not all databases are built the same way — a banking system needs guaranteed consistency, a social feed needs to handle massive scale, and an analytics warehouse needs to scan billions of rows in seconds. This guide to the types of databases in DBMS covers all five major categories, with real examples of where each is used, so you understand the landscape before deciding which database to learn first.

What are the Types of Databases?

A database type refers to how a database organizes, stores, and lets you query data, and different types exist because different applications have very different needs. The five major categories are relational, NoSQL (split further into document, key-value, column-family, and graph), hierarchical, network, and cloud databases. As a SQL learner you're focused on the relational model, which remains the dominant choice for structured business data — making it the best starting point in any guide to database types for beginners.

What You'll Learn

  • Identify the five major types of databases used in industry.
  • Understand the relational model and why SQL is built on it.
  • Compare NoSQL database subtypes: document, key-value, column-family, and graph.
  • Develop judgment for choosing the right database type for a given scenario.

Key Terms to Know

  • Relational database: Stores structured data in tables, uses SQL, and connects tables through keys.
  • NoSQL database: A broad category of non-relational databases built for flexibility, scale, or specialized access patterns.
  • Document database: A NoSQL database that stores data as JSON-like documents with no fixed schema.
  • Key-value store: A NoSQL database optimized for extremely fast lookups by a known key.
  • Graph database: A database built for highly connected data, like social networks, modeled as nodes and edges.

Relational Databases: The Foundation of SQL

Relational databases are still the most widely used database type in business applications — MySQL, PostgreSQL, Oracle Database, and Microsoft SQL Server are all relational. They store data in tables, enforce constraints, support transactions, and are queried using SQL. If you're building a web app, a banking system, or an e-commerce platform, a relational database is almost always the right first choice for your core data, which is exactly why most experts recommend it when choosing which database to learn first.

NoSQL Database Types: Document, Key-Value, Column-Family, and Graph

NoSQL database types emerged to handle workloads where the rigid relational model gets in the way. Document databases like MongoDB store data as flexible JSON-like documents, useful when an e-commerce catalog has products with wildly different attributes. Key-value stores like Redis act as ultra-fast lookup tables, ideal for caching, sessions, and leaderboards. Column-family databases like Cassandra are built for write-heavy workloads at massive scale, such as IoT sensor data. Graph databases like Neo4j model entities and their relationships as nodes and edges, which is exactly why LinkedIn uses one to power "People You May Know."

In a relational database vs NoSQL comparison, the real question isn't which is better, it's which data shape and access pattern actually fits your problem.

Hierarchical, Network, and Cloud Databases

Hierarchical databases, like IBM's IMS, use a tree structure where each record has exactly one parent, similar to folders containing subfolders. Network databases extended this hierarchical database model to allow multiple parents per record. Both are largely legacy today, but understanding them helps explain why the relational model was such a breakthrough when E.F. Codd proposed it in 1970.

Cloud databases aren't a separate data model at all, they're a deployment model. Common cloud database examples like Amazon RDS, Google Cloud SQL, and Azure SQL Database let you run MySQL or PostgreSQL with automatic backups, managed updates, and elastic scaling, without managing physical servers yourself.

Visual Summary

Picture a central box labeled Database Types branching into five categories: Relational (MySQL, PostgreSQL — tables and SQL), NoSQL (MongoDB, Redis, Cassandra, Neo4j — document, key-value, column-family, and graph), Hierarchical (IBM IMS — tree structure), Network (IDMS — multi-parent tree), and Cloud (Amazon RDS, Azure SQL — a managed layer over any of the above).

Database Types at a Glance

Database TypeData ModelBest Use CaseReal ExamplesSQL Used?
RelationalTables and rowsBusiness apps, transactions, reportsMySQL, PostgreSQL, OracleYes
Document (NoSQL)JSON documentsProduct catalogs, CMS, user profilesMongoDB, FirestoreNo (own query API)
Key-Value (NoSQL)Key → Value pairsCaching, sessions, leaderboardsRedis, DynamoDBNo
Column-family (NoSQL)Column familiesIoT, logging, time-series at scaleCassandra, HBaseNo
Graph (NoSQL)Nodes and edgesSocial networks, fraud detectionNeo4j, Amazon NeptuneNo
HierarchicalParent-child treeFile systems, legacy enterprise systemsIBM IMSLimited
Cloud (managed)Varies by engineReduced operations overheadAmazon RDS, Azure SQLDepends on engine

SQL Example

-- Relational database example: E-commerce product catalog
-- In a relational model, products and categories are connected through a foreign key

CREATE TABLE categories (
  category_id   INT          PRIMARY KEY AUTO_INCREMENT,
  category_name VARCHAR(100) NOT NULL UNIQUE
);

CREATE TABLE products (
  product_id   INT           PRIMARY KEY AUTO_INCREMENT,
  product_name VARCHAR(150)  NOT NULL,
  price        DECIMAL(10,2) NOT NULL CHECK (price > 0),
  stock_qty    INT           DEFAULT 0,
  category_id  INT,
  FOREIGN KEY (category_id) REFERENCES categories(category_id)
);

-- Find products in the 'Electronics' category under Rs 5000
SELECT p.product_name, p.price, p.stock_qty
FROM products p
JOIN categories c ON c.category_id = p.category_id
WHERE c.category_name = 'Electronics'
  AND p.price < 5000
  AND p.stock_qty > 0
ORDER BY p.price ASC;

Categories are stored once in their own table, and products reference them with a foreign key. A document database like MongoDB could store this too, but the relational model makes it easy to enforce category integrity, so a product can never be assigned to a category that doesn't exist.

Real-World Examples

  • Swiggy and Zomato run core operational data such as orders and payments on relational databases, while using Redis for real-time delivery tracking and caching.
  • LinkedIn uses a graph database to power "People You May Know," since social connections naturally form a graph of people and connections.
  • Uber stores ride events and driver telemetry in column-family databases like Cassandra, built for extremely high write volume and time-range scans.
  • Twitter and Instagram use key-value stores like Redis for session tokens and timeline caches, delivering sub-millisecond response times.

Best Practices and Pro Tips

  • Don't pick a database type because it's trendy — pick it because your data's actual shape and access pattern matches it. A flexible document store doesn't help if your data is genuinely tabular and relational.
  • It's normal, not exotic, for one production system to use several database types at once — MySQL for orders, Redis for sessions, and Elasticsearch for search is a common real-world combination.
  • If you're choosing your first database to learn, relational SQL skills transfer the most: tables, keys, and JOINs shape how you'll reason about NoSQL data modeling later too.

Common Mistakes to Avoid

  • Assuming NoSQL means no structure at all — document and column-family databases have their own schemas and query languages, just not a rigid relational one.
  • Choosing NoSQL because it sounds modern rather than because your data shape and consistency needs actually call for it.
  • Thinking a cloud database is a different data model — it's a deployment model, not a new way of structuring data.

Interview Questions

Q1. What are the main types of databases and when would you choose each?

Relational databases like MySQL suit structured business data needing transactions and SQL queries. Document databases like MongoDB suit flexible or nested data. Key-value stores like Redis are ideal for caching. Graph databases like Neo4j excel at connected data like social networks.

Q2. Is NoSQL better than SQL for all modern applications?

No. Relational databases remain the dominant choice for structured business data and ACID transactions. Many large applications combine both, for example transactional data in MySQL with a session cache in Redis.

Q3. What is a cloud database and what are its advantages?

A cloud database is a database service hosted and managed on infrastructure like AWS, Google Cloud, or Azure, offering automatic backups, auto-scaling, high availability, and managed updates without server provisioning.

Practice MCQs

1. Which database type stores data in tables and uses SQL?

  1. Document (NoSQL)
  2. Relational
  3. Graph
  4. Key-value

Answer: B. Relational

Explanation: Relational databases store data in rows and columns and are queried using Structured Query Language (SQL).

2. Redis is primarily an example of which database type?

  1. Relational
  2. Column-family
  3. Key-value store
  4. Graph

Answer: C. Key-value store

Explanation: Redis stores data as key-value pairs and is optimized for extremely fast in-memory lookups.

3. Which database type is best suited for storing a social network's friendship connections?

  1. Relational
  2. Key-value
  3. Column-family
  4. Graph

Answer: D. Graph

Explanation: Graph databases model data as nodes and edges, making them natural for social connections, recommendations, and fraud detection.

Quick Revision Points

  • Relational databases use tables, SQL, and ACID transactions — examples: MySQL, PostgreSQL, Oracle.
  • NoSQL subtypes: Document (MongoDB), Key-value (Redis), Column-family (Cassandra), Graph (Neo4j).
  • Hierarchical databases use a parent-child tree; network databases allow multiple parents.
  • Cloud databases are managed deployment models, not a separate data model.

Conclusion

  • Different database types solve different problems — no single database wins every scenario.
  • Relational databases remain the most important for SQL learners, since they dominate business use and interviews.
  • Many real production systems combine database types, like MySQL for transactions and Redis for caching.

Database types evolved to serve different data needs: relational databases power structured business applications with SQL and referential integrity, NoSQL databases serve flexible or high-scale workloads, and cloud databases bring managed infrastructure to any of them. In any sql vs nosql comparison, the honest answer is that the right database type depends entirely on your data's shape and access pattern, and as a SQL learner, you're mastering the type still used most widely in business, finance, and enterprise applications worldwide.

Frequently Asked Questions

Beginners should start with a relational database such as MySQL or PostgreSQL. SQL is a universal language in data engineering, backend development, and analytics. Relational databases dominate job requirements at the entry level, and the concepts of tables, keys, and JOINs transfer well to understanding other database types later.

SQL databases (relational) use structured tables, a fixed schema, and SQL for querying. They emphasize ACID transactions and data integrity. NoSQL databases use flexible data models such as documents, key-value pairs, graphs, or column families. They often prioritize horizontal scalability and flexible schemas over strict consistency.

MongoDB is a NoSQL document database. It stores data as BSON documents (similar to JSON) and uses its own query language rather than SQL. Each document can have different fields, making it suitable for flexible data structures.

Redis is a key-value store used for caching database query results to reduce load, storing user session tokens, maintaining real-time leaderboards, publishing and subscribing to messages in event-driven systems, and storing frequently accessed data in memory for microsecond response times.

Because different parts of an application have different data needs. The user account and order system may need ACID relational storage in MySQL. The search feature may use Elasticsearch. The session management uses Redis for speed. The analytics warehouse uses Redshift for large-scale aggregations. Each database is chosen to optimize for its specific workload.

ACID stands for Atomicity (all-or-nothing transactions), Consistency (database always moves from one valid state to another), Isolation (concurrent transactions do not interfere with each other), and Durability (committed transactions survive crashes). Relational databases are designed to guarantee ACID properties.