key-value store
A key-value store is the simplest NoSQL architectural pattern where data is stored as a pair consisting of a unique key and its associated value. The key acts like an identifier (similar to a word in a dictionary), and it directly points to the value, which can be any type of data such as text, images, documents, or videos. These systems do not use complex query languages; instead, they rely on basic operations like put (insert/update), get (retrieve), and delete (remove). Because of their simple structure, key-value stores provide fast data access, high scalability, and flexibility, making them suitable for applications like caching, storing web pages, session management, and handling large amounts of unstructured data.
What is a Key–Value Store?
A key–value store is the simplest type of NoSQL database. It stores data as a collection of pairs, where:
-
A key → is a unique identifier (like a name)
-
A value → is the data associated with that key (can be anything)
👉 When you provide a key, the system directly returns its corresponding value.
Core Idea
Think of it like a dictionary:
| Dictionary Concept | Key–Value Store Equivalent |
|---|---|
| Word | Key |
| Definition | Value |
-
Just like you quickly find a word’s meaning using the word itself,
-
A key–value store retrieves data instantly using the key.
Key Characteristics
1. Simple Data Model
-
No tables, rows, or schemas (unlike relational databases)
-
Just key → value pairs
2. No Query Language
-
You cannot perform complex queries like SQL (
JOIN,WHERE, etc.) -
Only basic operations:
-
PUT → add/update a key-value pair
-
GET → retrieve value using key
-
DELETE → remove a key-value pair
-
3. Fast Data Retrieval
-
Data is indexed by key
-
No need to scan the database
-
Retrieval time is nearly constant, regardless of size
4. Flexible Data Storage (BLOB-based)
-
Values are stored as BLOBs (Binary Large Objects)
-
The database does not interpret the data type
👉 This means values can be:
-
Strings
-
JSON / XML
-
Images
-
Videos
-
Documents
✔️ The application (not the database) decides how to interpret the data.
Flexibility of Keys
Keys can take many forms, such as:
-
File paths (e.g.,
/images/logo.png) -
Generated hashes
-
URLs or REST API calls
-
Even SQL-like strings
👉 The only requirement: each key must be unique
Flexibility of Values
Values can be anything, including:
-
Web pages
-
Images
-
Videos
-
Binary files
-
Structured or unstructured data
Example
Why Use Key–Value Stores?
Advantages
-
Extremely fast (direct lookup)
-
Highly scalable
-
Simple to implement
-
Flexible data storage
Limitations
-
No complex querying
-
No relationships between data
-
Limited structure enforcement
Summary
A key–value store:
-
Stores data as key–value pairs
-
Provides fast, direct access
-
Uses simple operations instead of queries
-
Supports any type of data via BLOBs
-
Leaves interpretation of data to the application
Using a Key–Value Store
Conceptual View
The easiest way to understand usage is to imagine a simple table with two columns:
| Key (unique) | Value (data) |
|---|---|
user:101 | User info |
/img/logo | Image data |
-
Key → unique identifier
-
Value → actual data (stored as a BLOB)
Core API Operations
A key–value store is accessed through a simple API (Application Programming Interface) with only three operations:
1. PUT (Insert / Update)
✔ What it does:
-
Adds a new key–value pair
-
Updates value if the key already exists
📌 Example:
👉 Stores:
| Key | Value |
|---|---|
| 123 | value123 |
2. GET (Retrieve)
✔ What it does:
-
Retrieves the value associated with a key
-
Returns error if key does not exist
📌 Example:
👉 Returns:
3. DELETE (Remove)
✔ What it does:
-
Removes a key and its value
-
Returns error if key not found
📌 Example:
👉 Result:
-
Key
789is removed from the store
Fundamental Rules
1. 🔑 Distinct Keys (Uniqueness)
-
Every key must be unique
-
No duplicate keys allowed
👉 Why?
-
Ensures exact retrieval of one value
2. No Queries on Values
-
You cannot search using values
-
No SQL-like queries (
WHERE,JOIN, etc.)
👉 Example NOT allowed:
✔ Instead:
-
You must already know the key
How Applications Use It
📌 Workflow Example (Image Storage)
Store an image:
Retrieve the image:
Delete the image:
👉 The application decides:
-
What the key represents (file path, ID, etc.)
-
What the value contains (image, JSON, etc.)

REST API Connection
-
The term PUT aligns with REST architecture
-
Key–value stores often expose RESTful APIs
👉 Example:
Design Trade-Off
✔ Key Insight:
Complexity is shifted from the database to the application
| Relational DB | Key–Value Store |
|---|---|
| Complex queries | No queries |
| DB handles relationships | Application handles logic |
| Structured schema | Flexible data |
Why It’s General-Purpose
A key–value store is often called a:
👉 “Swiss Army knife of databases”
✔ Because:
-
You define:
-
Key structure
-
Data format
-
-
It supports:
-
Text
-
Images
-
Videos
-
Documents
-
Real-World Use Cases
1. 🌍 Web Page Storage
-
Entire websites stored as:
-
Key → URL
-
Value → HTML content
-
👉 Used by search engines
2. ☁️ Cloud Storage (e.g., S3-like systems)
-
Key → file name/path
-
Value → file content
✔ Ideal for:
-
Images
-
Audio
-
Video
-
Backups
Summary
“A key–value store is used by calling simple functions—put, get, and delete—to store and retrieve data using a unique key. Unlike relational databases, it doesn’t search data; instead, it retrieves data instantly if you already know the key.”
Uses 3 simple operations: PUT, GET, DELETE
-
Requires unique keys
-
No querying on values
-
Stores any type of data (BLOBs)
-
Application controls data logic
Use Case: Amazon S3
📌 Overview
-
Amazon S3 is an online storage service (launched in 2006)
-
It is essentially a key–value store exposed via a REST API
-
Used to store large volumes of digital assets like:
-
Images
-
Audio files
-
Videos
-
Core Structure
🪣 Buckets
-
Data is stored inside buckets
-
A bucket contains key–object pairs
Key–Value Mapping
-
Key → unique string identifier
-
Value (Object) → actual data (file, media, document)
-
Keys must be unique within a bucket
Operations (via REST API)
S3 uses standard HTTP methods:
| Operation | Description |
|---|---|
| PUT | Upload/store an object |
| GET | Retrieve an object |
| DELETE | Remove an object |
Accessing Data
-
Objects are accessed via a URL
📌 Example:
👉 This allows:
-
Access from anywhere on the web
-
Easy integration into applications
Key Features
1. Metadata Support
-
Attach extra information to objects:
-
Content type
-
Size
-
Cache settings
-
Expiry
-
2. Access Control
-
Permissions can be set for:
-
Individuals
-
Groups
-
Public access
-
👉 Controls who can:
-
Upload (PUT)
-
Retrieve (GET)
-
Delete objects
Why Use S3 (Key–Value Store Advantage)
-
Highly scalable (millions of objects)
-
Simple interface (REST-based)
-
Cost-effective storage
-
Ideal for multimedia and large files
Summary
“Amazon S3 is a real-world example of a key–value store where data is stored as objects inside buckets, accessed using unique keys, and manipulated using simple REST operations like PUT, GET, and DELETE.”
Key Takeaway
-
S3 demonstrates how key–value stores power large-scale storage systems
-
It shifts complexity away from databases and provides:
-
Simplicity
-
Flexibility
-
Global accessibility
-



Comments
Post a Comment