For years, we’ve been told to pick our poison: the rigid structure of SQL, the flexibility of NoSQL, or the complex relationship mapping of Graph databases. But after spending a few weeks with SurrealDB, I’m starting to think that choice is becoming obsolete. In this surrealdb review and tutorial, I’ll break down whether this ‘multi-model’ database actually delivers on its promise or if it’s just another piece of hype in the data landscape.
When I first started exploring the beginner guide to nosql vs sql databases, the trade-off was always about consistency versus scalability. SurrealDB claims to solve this by being a relational database, a document store, and a graph database all in one. More importantly, it acts as its own API layer, potentially eliminating the need for a separate backend server in some architectures.
The Strengths: Why SurrealDB is Impressive
After integrating SurrealDB into a small internal tool project, a few things immediately stood out to me:
- Unified Data Model: I can store a document, link it to another record using a graph edge, and query it with SQL-like syntax without jumping between different engines.
- Schemaflexibility: You can start schemaless (like MongoDB) and gradually enforce a schema as your project matures, which is a godsend for rapid prototyping.
- Built-in Permissions: The permission system is incredibly granular. I can define access control directly at the database level, meaning the frontend can query the DB securely without a middle-man Express or Go server.
- Real-time Capabilities: Live Queries allow the frontend to subscribe to changes. When a record updates, the UI updates instantly via WebSockets.
- Powerful Query Language: SurrealQL is intuitive. If you know SQL, you’re 80% there, but with the added power of graph traversals.
- Deployment Flexibility: Whether you need it embedded in a Rust app or running as a distributed cluster, it fits.
The Weaknesses: Where It Falls Short
No tool is perfect, and SurrealDB has some growing pains that you should be aware of:
- Learning Curve for Graph Logic: While SQL is easy, thinking in ‘edges’ and ‘relations’ takes a mental shift, similar to what you’ll find when researching why use a graph database for social networking.
- Ecosystem Maturity: Compared to PostgreSQL or MongoDB, the community plugins, ORM support, and third-party GUI tools are still relatively sparse.
- Documentation Gaps: While the core docs are great, some of the more advanced distributed configurations can feel a bit thin.
Quick Tutorial: Getting Started with SurrealDB
Let’s move from the review to the practical side. Here is how to get a basic instance running and perform your first operations.
Step 1: Installation
The fastest way to start is via the terminal. Run this command to install the SurrealDB binary:
curl -sSf https://install.surrealdb.com | sh
Step 2: Starting the Server
Start a local development server in memory for speed:
surreal start --user root --pass root memory
Step 3: Creating Data with Relations
One of the most powerful features is the ability to create relations without join tables. Here is how I set up a simple ‘User’ and ‘Post’ relationship:
-- Create a user
CREATE user:jane SET name = 'Jane Doe', email = 'jane@example.com';
-- Create a post
CREATE post:hello_world SET title = 'Hello SurrealDB', content = 'This is amazing!';
-- Relate them (Graph approach)
RELATE user:jane -> wrote -> post:hello_world SET date = time::now();
As shown in the image below, the way SurrealDB handles these relations is visually different from traditional foreign keys, treating the connection as a first-class entity.
Step 4: Querying the Graph
Now, let’s fetch all posts written by Jane using a graph traversal:
SELECT ->wrote->post.* FROM user:jane;
This single line replaces what would typically be a complex JOIN statement in SQL.
Performance and User Experience
In my experience, read speeds for document-style queries are on par with MongoDB. However, the real performance win happens during deep relationship queries. In a traditional SQL DB, joining five tables is a nightmare for the optimizer; in SurrealDB, traversing those same five links is a native operation.
The developer experience (DX) is top-notch. The Surrealist GUI provides a clean interface for managing data, though I still find myself spending 90% of my time in the CLI for precise control.
Comparison: SurrealDB vs. The Giants
| Feature | PostgreSQL | MongoDB | SurrealDB |
|---|---|---|---|
| Model | Relational | Document | Multi-Model |
| Schema | Strict | Flexible | Both (Hybrid) |
| Graph Support | Via Extensions | Limited | Native |
| API Layer | External Required | External Required | Built-in |
Who Should Use SurrealDB?
I wouldn’t recommend SurrealDB for every project. If you are building a simple CRUD app with a very stable schema, stick with PostgreSQL. However, you should consider SurrealDB if:
- You are building a social network, knowledge graph, or recommendation engine.
- You want to reduce backend boilerplate by using the database’s built-in permission and API layers.
- You need real-time updates without setting up a separate Socket.io or Pusher server.
- You find yourself juggling three different databases (e.g., Redis, Mongo, and Postgres) for one application.
Final Verdict
SurrealDB is an ambitious project that successfully collapses the distance between the database and the API. While the ecosystem is still maturing, the ability to perform complex graph queries with SQL-like ease is a game-changer. It has significantly streamlined my development workflow by removing the ‘middle-man’ code. My rating: 4.5/5 for innovation, 3.5/5 for ecosystem maturity.