Types of Databases
Not every database works the same way. The model a database uses determines how it stores data, how you query it, and what kinds of problems it solves best. Choosing the wrong type is a costly mistake.
Not All Databases Are Alike
A database is defined by its model — the way it organises and structures data internally. Different models are better suited to different problems. Choosing the wrong model for your data is one of the most expensive architectural mistakes a developer can make.
There are four major database models in widespread use today, each with a clear philosophy, strengths, and weaknesses.
1. Relational Databases
The dominant model since the 1970s. Data is organised into tables (rows and columns), and tables relate to each other through shared keys. Based on solid mathematical foundations (relational algebra, set theory). Queried using SQL.
Students Table
┌────────────┬─────────────┬─────┐
│ student_id │ name │ age │
├────────────┼─────────────┼─────┤
│ cen/01 │ Kondwani │ 21 │
│ ict/02 │ Chisomo │ 23 │
└────────────┴─────────────┴─────┘
Enrolments Table — links via student_id
┌────────────────┬────────────┬───────────────── ┐
│ enrolment_id │ student_id │ course │
├──────────────┼────────────┼─────────────────────────┤
│ 101 │ cen/01 │ Web Development │
│ 102 │ cen/01 │ Spiritual formation │
│ 103 │ ict/02 │ Trigonometry │
└──────────────┴────────────┴───────────────── ┘
2. Document Databases (NoSQL)
Store data as documents — typically JSON or BSON format. Each document is self-contained and can have its own structure. No rigid schema required. Excellent for flexible, hierarchical data.
// Each student is a self-contained document
{
"_id": "cen/01",
"name": "Kondwani",
"age": 21,
"courses": ["Computer Architecture", "C++"],
"address": {
"city": "Mzuzu",
"country": "Malawi"
}
}
3. Key-Value Stores
The simplest model — data stored as pairs of a unique key and a value. Extremely fast for lookups. Used primarily for caching and session management.
session:user_42 → { name: "Kondwani", role: "student" }
cache:homepage → "<html>...cached HTML...</html>"
counter:page_views → 18472
token:abc123def → { user_id: 42, expires: 1720000000 }
4. Graph Databases
Store data as nodes (entities) and edges (relationships). Designed for highly connected data where the relationships themselves are as important as the data.
Nodes (entities) and Edges (relationships)
(Kondwani) -[ENROLLED_IN]→ (Web Development)
(Kondwani) -[FRIENDS_WITH]→ (Chisomo)
(Chisomo) -[ENROLLED_IN]→ (Networks)
(Web Development) -[TAUGHT_BY]→ (Mr Phiri)
Relational databases are commonly referred to as SQL databases because they use the Structured Query Language (SQL) to manage and query data. Other modern database models such as document, key-value, and graph databases are often grouped under the term NoSQL. Originally meaning "No SQL", the term is now widely interpreted as "Not Only SQL", indicating that these systems do not rely solely on the relational model. The best choice depends on the structure of your data, scalability needs, and the problem you are trying to solve.