Database Types Learning Hub

Master the essential database types and design your own schemas with interactive tools

Database Types Overview

πŸ“Š

Relational (SQL)

Structured data in tables with relationships

Examples: MySQL, PostgreSQL, Oracle
πŸ“„

Document Store

JSON-like documents with flexible schemas

Examples: MongoDB, CouchDB
πŸ”‘

Key-Value Store

Simple key-value pairs for fast lookups

Examples: Redis, DynamoDB
πŸ•ΈοΈ

Graph Database

Nodes and relationships for connected data

Examples: Neo4j, ArangoDB

Relational Database (SQL)

What is it?

Relational databases organize data into tables (relations) with rows and columns. Data is structured and relationships are defined using foreign keys.

βœ“ Strengths

  • ACID compliance (reliable transactions)
  • Strong data integrity
  • Complex queries with JOINs
  • Mature ecosystem

βœ— Limitations

  • Rigid schema
  • Vertical scaling challenges
  • Can be slower for certain workloads
  • Complex for hierarchical data

Example Schema

Users
id (PK)
username
email
Orders
id (PK)
user_id (FK)
total
date
CREATE TABLE Users (
    id INT PRIMARY KEY,
    username VARCHAR(50),
    email VARCHAR(100)
);

CREATE TABLE Orders (
    id INT PRIMARY KEY,
    user_id INT,
    total DECIMAL(10,2),
    date DATE,
    FOREIGN KEY (user_id) REFERENCES Users(id)
);

Best Use Cases

E-commerce Banking Systems ERP Systems CRM Applications

Document Database

What is it?

Document databases store data in JSON-like documents. Each document is self-contained and can have a different structure, providing flexibility.

βœ“ Strengths

  • Flexible schema
  • Easy to scale horizontally
  • Natural data representation
  • Fast for read-heavy workloads

βœ— Limitations

  • Limited JOIN support
  • Data duplication possible
  • Eventual consistency in some cases
  • Complex transactions harder

Example Document

{
    "_id": "user123",
    "username": "john_doe",
    "email": "john@example.com",
    "profile": {
        "age": 30,
        "location": "New York"
    },
    "orders": [
        {
            "orderId": "order456",
            "total": 99.99,
            "date": "2025-01-15",
            "items": ["item1", "item2"]
        }
    ],
    "tags": ["premium", "verified"]
}

Best Use Cases

Content Management User Profiles Catalogs Real-time Analytics

Key-Value Database

What is it?

Key-value stores are the simplest NoSQL databases. They store data as a collection of key-value pairs, like a large hash table.

βœ“ Strengths

  • Extremely fast lookups
  • Simple to use
  • Highly scalable
  • Great for caching

βœ— Limitations

  • No complex queries
  • Limited search capabilities
  • No relationships between data
  • Simple data model only

Example Data

user:123:name β†’ "John Doe"
user:123:email β†’ "john@example.com"
session:abc123 β†’ {"userId": 123, "expires": "2025-12-13"}
cart:user123 β†’ ["item1", "item2", "item3"]

Best Use Cases

Caching Session Storage Shopping Carts Rate Limiting

Graph Database

What is it?

Graph databases use graph structures with nodes, edges, and properties to represent and store data. Perfect for highly connected data.

βœ“ Strengths

  • Fast relationship queries
  • Intuitive for connected data
  • Flexible structure
  • Pattern matching

βœ— Limitations

  • Learning curve for query language
  • Not ideal for simple queries
  • Scaling can be complex
  • Smaller ecosystem

Example Graph

Alice Bob Company Carol KNOWS WORKS_AT FRIEND_OF
// Create nodes
CREATE (alice:Person {name: 'Alice', age: 30})
CREATE (bob:Person {name: 'Bob', age: 28})
CREATE (company:Company {name: 'TechCorp'})

// Create relationships
CREATE (alice)-[:KNOWS]->(bob)
CREATE (alice)-[:WORKS_AT]->(company)
CREATE (bob)-[:FRIEND_OF]->(carol)

Best Use Cases

Social Networks Recommendation Engines Fraud Detection Knowledge Graphs

Database Schema Designer

Click "Add Table/Collection" to start designing

Generated Schema

// Your schema will appear here

Database Type Comparison

Feature Relational Document Key-Value Graph
Schema Fixed/Rigid Flexible Schema-less Flexible
Scalability Vertical Horizontal Horizontal Complex
Query Complexity High (JOINs) Medium Low (Simple) High (Paths)
Consistency ACID Eventual Eventual ACID
Performance Good Excellent Very Fast Fast (Relations)
Data Integrity Strong Medium Low Strong

Decision Helper

Choose your primary requirement: