Karthik Divi
·3 min read

SurrealDB Online Compiler and SQL Editor

SurrealDB is one of the newer databases that tries to be several things at once: document store, graph database, and relational database, all accessible through a single query language called SurrealQL. It is an ambitious project. Whether you are storing JSON-like documents, defining graph relationships between records, or running traditional filtered queries, you use the same syntax.

The downside of being new is that most developers have not used it before. And the best way to get a feel for SurrealQL is to just write some queries. You could install the SurrealDB binary, start a server, connect a client -- or you could open a browser tab and start typing.

Why an online SurrealDB editor is worth using

SurrealDB's query language looks familiar if you know SQL, but it has its own patterns. Record IDs work differently. You create records with CREATE, not INSERT (though INSERT works too). Graph edges are first-class. These are things you want to try interactively.

An online editor is good for:

  • Learning SurrealQL syntax without committing to a local install
  • Testing multi-model patterns: documents, relations, and graph traversals in one place
  • Sharing examples with your team when evaluating SurrealDB as a technology choice
  • Quick prototyping of data models before building them into an application

SurrealQL code example

Here is a taste of how SurrealDB handles record creation and graph relationships:

-- Create some people
CREATE person:alice SET name = 'Alice', role = 'engineer', joined = '2024-03-01';
CREATE person:bob SET name = 'Bob', role = 'designer', joined = '2024-06-15';
CREATE person:carol SET name = 'Carol', role = 'engineer', joined = '2023-11-20';

-- Create a project
CREATE project:webapp SET title = 'Customer Portal', status = 'active';

-- Define relationships using graph edges
RELATE person:alice->works_on->project:webapp SET since = '2024-04-01';
RELATE person:bob->works_on->project:webapp SET since = '2024-07-01';
RELATE person:carol->mentors->person:alice SET topic = 'system design';

-- Query: who works on the webapp?
SELECT name, role FROM person WHERE ->works_on->project:webapp;

-- Query: who does Carol mentor?
SELECT ->mentors->person.name AS mentees FROM person:carol;

Notice how the arrow syntax (->works_on->) lets you traverse graph edges directly in a SELECT. No joins, no junction tables. This is one of the things that makes SurrealDB interesting to experiment with -- it genuinely feels different from writing plain SQL.

Local setup vs. browser

SurrealDB is straightforward to install locally, but there is a gap between "I want to see what this database is about" and "I want to set up a local instance." An online editor closes that gap.

It is especially useful when:

  • You are evaluating SurrealDB and do not want to install it yet
  • You want to test a SurrealQL pattern you read about in the docs
  • Someone on your team has never seen SurrealDB and you want to show them a live example
  • You are working through a tutorial and want fast feedback

Run SurrealQL on OneCompiler

OneCompiler supports SurrealDB with its SurrealQL syntax. You can create records, define graph edges, and query across models right in the browser.

Start here: SurrealDB Online Compiler on OneCompiler

If you are curious about SurrealDB but have not tried it yet, this is probably the lowest-friction way to start.