DEV Community

Cover image for SurrealDB: Why JOINs are So 2010 and How Graphs Change Everything (Part 3)
Jakub Málek
Jakub Málek

Posted on

SurrealDB: Why JOINs are So 2010 and How Graphs Change Everything (Part 3)

The Mental Gymnastics of Data
We’ve all been there. You start with a simple Document DB because "it’s flexible." Then your boss says: "Hey, can we show which friends of this user liked the same products in the last 24 hours?"

Suddenly, your "flexible" NoSQL setup becomes a nightmare of application-side joins, or you’re staring at a SQL query so long it looks like a spell from Harry Potter.

As a medior dev, I’ve learned that the hardest part of coding isn't the logic—it's managing the relationships between data without losing your mind. That’s where the "Surreal" in SurrealDB finally clicks.

Graphs vs. Joins: The Arrow Power 🏹
In traditional SQL, you have "Join Tables" (the middleman nobody likes). In SurrealDB, records can point to each other directly using Graph relations.

Instead of a 20-line JOIN statement, you use arrows. It’s intuitive, it’s fast, and it’s actually readable:

-- Find all products liked by people I follow
SELECT ->follows->person->liked->product FROM user:tobias;
Enter fullscreen mode Exit fullscreen mode

Read that again. It’s like writing a sentence. follows and liked aren't just strings; they are edges that can hold their own data (like when you followed them).

The Multi-Model Secret: You Don't Have to Choose
The biggest "Lazy Dev" win? You don't need a separate Graph DB (like Neo4j) and a Document DB (like MongoDB).

  • Want to store a messy JSON? Go for it.
  • Want to enforce a strict schema? One command away.
  • Want to link them with graph edges? It’s already built-in.

It’s the "Swiss Army Knife" of databases. For someone like me who balances Frontend, AI, and startup chaos, not having to manage three different database clusters is a lifesaver.

AI and Connected Data
Since I’m building a watchdog for AI trust levels, I need to see how data points connect. AI thrives on context. SurrealDB’s ability to traverse relationships instantly makes it the perfect backbone for AI-driven apps where context is everything.

The Series Wrap-Up: Is SurrealDB for You?
We’ve covered the "What," the "Backend-less" magic, and the "Graph" power.

My verdict? If you’re building a massive legacy banking system, stick to your COBOL and PostgreSQL. But if you’re a freelancer, a startup founder, or just a developer who values their time and sanity—give SurrealDB a spin.

It’s not just a database; it’s a way to make development fun again.

Top comments (0)