Specialized Stores: Time-Series and Graph Databases
Understand the idea
When to adopt time-series or graph databases, and when to resist architectural sprawl.
The idea
Beyond relational, document, and vector databases, two other specialized database types solve specific engineering problems:
- Time-Series Databases (e.g. TimescaleDB, InfluxDB): Built for streams of timestamped numbers (server metrics, weather sensor readings, financial stock ticks). They organize data by time chunks, compress old history by up to 90%, and quickly calculate rolling averages over minutes, hours, or days.
- Graph Databases (e.g. Neo4j, Amazon Neptune): Built for datasets where the connections between items matter just as much as the items themselves. Each entity points directly to connected entities in memory. Finding friends-of-friends, mapping fraud networks, or checking user permissions takes milliseconds instead of requiring slow recursive .
A key lesson for engineers is to avoid tool clutter: every extra database you add means another system to back up, monitor, and maintain. Use PostgreSQL for your main data, use a like Redis for caching, and only add specialized databases when your data volume genuinely demands it.
What changes
| Attribute | Time-Series (TimescaleDB / InfluxDB) | Graph (Neo4j) | Relational (PostgreSQL) |
|---|---|---|---|
| Primary Data Shape | Append-only timestamp + measurement metric | Nodes (entities) and directed Edges (relations) | Structured tabular rows and foreign keys |
| Key Optimization | High write ingestion + time-based compression | Pointer-chasing multi-hop edge traversal | Balanced general-purpose queries and ACID safety |
| Best Workload | Server metrics, IoT telemetry, stock trades | Social networks, fraud rings, dependency trees | Standard web applications, e-commerce, SaaS |
The command
Graph traversal: 2nd-degree friend connections
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
The mistake
Check the result
Run the example to see graph traversal compute second-degree friends across connected nodes without issuing multi-table joins.
Guided challenge
Identify time-series workloads
Update the function so it returns true when isAppendOnlyTimestamped is true, and false when false.
Identify time-series workloads
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
EXPECTED RESULT
true false
Hints 0/1
Use all hints or make 3 failed checks (0/3).
Free exploration
Change this example and run it again. Each run is a new process. Nothing is saved.
Your variation
3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.
Quiz
A quick check for understanding. Retry as often as you like; your learning path stays open.
Ready to call this one understood?
Mark this lesson complete to earn 150 XP. You can always revisit it.