Modern application architectures often end up with sprawling database sprawl: PostgreSQL for relational data, MongoDB for JSON documents, Neo4j for social graphs, and Redis for pub/sub real-time events. Maintaining four different database backends creates high DevOps complexity. SurrealDB consolidates these capabilities into a single multi-model engine written in Rust.
Key Architectural Innovations
- Graph Relations Without Foreign Keys: Link records using first-class directional pointers (e.g.
RELATE user:123->likes->post:456) and traverse deep relationships in sub-millisecond queries without expensive SQL table joins. - Flexible Modes (Embedded to Distributed): Can run in-memory for testing, embedded directly inside a Rust app (like SQLite), or distributed across Kubernetes clusters backed by TiKV.
- Direct Frontend Connectivity: With built-in authentication and row-level permissions, web and mobile apps can query SurrealDB directly via WebSockets without needing an intermediate backend API layer.
SurrealDB Unified Multi-Model Engine
SurrealDB vs Traditional Relational and Document Stores
| Feature | SurrealDB | PostgreSQL | MongoDB |
|---|---|---|---|
| Data Models | Document + Graph + Relational | Relational + JSONB | Document Only |
| Graph Relations | Native pointer syntax (`->`) | Recursive CTEs / Foreign keys | `$lookup` aggregation |
| Realtime Live Queries | Native `LIVE SELECT` streams | Requires LISTEN/NOTIFY | Change streams (Oplog) |
When launching SurrealDB via CLI or Docker, running surreal start without specifying a storage backend will default to an in-memory database (memory). In memory mode, all data is permanently discarded when the process exits or container reboots. To persist your database to disk, always specify a storage file prefix: surreal start --user root --pass root file:/path/to/data.db.
Explore SurrealDB at surrealdb.com or inspect the code on GitHub.
Discussion & Issues
Comments
Post a Comment