NoSQL Databases — Quick Overview
Database System Theory — Week 16 (Elmasri Ch. 24)
This is a quick, plain-language overview of three related ideas: why NoSQL databases exist, what key-value
stores are, and what graph databases are.
1. Why NoSQL? (The Motivation)
Relational databases (tables, rows, fixed schemas) work great for structured data, but they start to struggle with
very large-scale, fast-changing, or loosely-structured data — think social media feeds, sensor data, or
e-commerce catalogs with millions of users. NoSQL ("Not Only SQL") databases were built to handle exactly
these situations.
●
Scalability: NoSQL systems are designed to scale out across many cheap servers (horizontal scaling), rather
than scaling up one big expensive server.
●
Flexible schema: data doesn't need a fixed table structure decided in advance — useful when data shapes
vary or change often.
●
High performance: optimized for very fast reads/writes at massive scale, sometimes by relaxing strict
consistency guarantees (trading some consistency for speed and availability).
●
Specialized data shapes: some data (e.g., networks of relationships, simple lookups) maps more naturally onto
non-relational models.
2. Key-Value Stores
The simplest type of NoSQL database. Think of it like a giant dictionary or hash map: every piece of data is
stored as a key (a unique identifier) paired with a value (the actual data, which can be almost anything — a
string, a number, a JSON object, a file). The database doesn't care what's inside the value; it just stores and
retrieves it by key, extremely fast.
Key Value
user:1024 { name: "Ali", cart: ["itemA", "itemB"] }
session:9f3a { loggedIn: true, expires: "18:00" }
Good for: caching, session storage, shopping carts, user preferences — anything that's looked up by a simple ID
and doesn't need complex queries. Examples: Redis, Amazon DynamoDB, Riak.
3. Graph Databases
Graph databases store data as nodes (entities, e.g. a person, a place, a product) connected by edges
(relationships, e.g. "FRIENDS_WITH", "PURCHASED", "LOCATED_IN"). Both nodes and edges can hold their
own properties (e.g., a "FRIENDS_WITH" edge might have a "since: 2021" property). The model is built
specifically to make it fast to traverse relationships, something relational databases get slow at once you need
many chained joins.
Example: Alice → FRIENDS_WITH → Bob → WORKS_AT → Acme Corp. A graph database can quickly answer
questions like "who are Alice's friends-of-friends?" or "what's the shortest connection path between two people?"
— queries that would require many expensive joins in a relational database.
Good for: social networks, recommendation engines, fraud detection, knowledge graphs, network/route
mapping. Examples: Neo4j, Amazon Neptune.
In short: NoSQL trades some of the structure and strict consistency of relational databases for scale, flexibility,
and speed — key-value stores optimize for simple fast lookups, while graph databases optimize for exploring
connected relationships.
SSUET — Database System Theory Page 1