SurrealDB: Multi-Model Records, Graph Links and Live Queries
Documents, graph edges and realtime in one engine with one query language - and a youth that is a design input rather than a disclaimer.
SurrealDB is a genuinely ambitious database. One engine holds documents, graph edges and relational-style tables; one language, **SurrealQL**, queries all of them; record identifiers are first-class values so a link is a pointer you traverse rather than a join you write; graph edges are themselves records with their own fields; permissions are declared per record in the schema rather than enforced in your application; and **`LIVE SELECT` pushes changes to subscribed clients over a websocket**, so realtime is a database feature rather than a layer you build on top. For an application that is simultaneously document-shaped, graph-shaped and collaborative, the reduction in moving parts is real and substantial.
Overview
**First, verify against your version, always.** SurrealQL's behaviour, the query planner's capabilities, index support, transaction semantics and permission evaluation have all moved across minor releases. Documentation and community answers may describe intent, a different version, or a feature that has since been renamed. **The habit this course builds is to test the behaviour you depend on in your own sandbox and write down the version you tested on** - which is good practice everywhere and is load-bearing here.
**Second, the storage backend is the operational decision, and it is made before anything else.** In-memory, a local file store, or a distributed key-value store underneath: that choice determines your durability, whether you have a cluster at all, how you back up, and what a node failure means. It is not a tuning knob you revisit later.
**Third, plan every upgrade as a migration until proven otherwise.** SurrealDB has made breaking changes across major versions, including to on-disk format, where the path forward was export and reimport rather than an in-place upgrade. So **design the application so the database can be rebuilt**, keep your export path tested, and treat a major version bump as a project with a rehearsal.
None of that argues against using it. It argues for using it **with the operational assumptions that match it** - which is a more useful thing to learn than either enthusiasm or dismissal.
Seven modules, about 70 hours. The capstone is a collaborative project tracker combining documents, graph links and live updates.
Introduction
For a sandbox, run SurrealDB in Docker with the **file-backed store** - that is the configuration closest to a real single-node deployment, and the in-memory one hides every durability question you need to think about. **Record the exact version in your README on day one**, and re-record it whenever you upgrade, because you will need it to interpret your own notes later.
You also need a **project tracker dataset generator**, written in Module 1 and used throughout: organisations, users, projects, tasks with parent and child relationships, comments, attachments and an activity stream, at a configurable scale, with realistic graph density. The capstone is built on it, and the live-query work needs the ability to drive concurrent mutations through it.
One habit from the start: **when the documentation and the engine disagree, the engine is right.** Write a small test for every behaviour you are going to rely on - does this permission clause actually deny, does this index actually get used, does this transaction actually roll back, does a live query actually deliver that event. The test suite you accumulate is the single most valuable artefact of this course, and it is what makes an upgrade survivable.
What you will be able to do
- Explain namespaces, databases, tables, records and record identifiers
- Write SurrealQL for CRUD, filtering, aggregation and nested data
- Use record links and explain how they differ from joins
- Create graph edges with RELATE and traverse them in both directions
- Choose between schemafull and schemaless tables with reasons
- Define fields, types, assertions and indexes, and verify they are enforced
- Choose a storage backend and state what it determines
- Use transactions, and verify their actual behaviour on your version
- Define functions and events, and explain when an event fires
- Implement record-level permissions and test every denial
- Build a live query subscription and handle the reconnection problem
- Design full-text and vector search with analyzers and indexes
- Read query plans where available and design indexes from evidence
- Set and justify traversal limits
- Export and import, and measure both
- Plan recovery for your storage backend, including rebuild
- Plan an upgrade as a rehearsed migration
- Produce a deployment, tenancy and cost checklist
What each level covers
5 levels · 7 lessons
-
Beginner - Foundations
The record model, SurrealQL and the storage backend decision; then modelling with links and edges.
2 lessons 15 min of reading
Start with Namespaces, Records, SurrealQL and the Storage Backend → -
Intermediate - Application Behaviour
The SDK, transactions, events and permissions; then live queries and the reconnection problem that defines them.
1 lesson 11 min of reading
Start with Transactions, Functions, Events, Permissions and Live Queries → -
Advanced - Performance and Reliability
Index design, search and traversal cost; then recovery, which here means export and rebuild.
2 lessons 16 min of reading
Start with Query Plans, Index Design, Search, Vectors and Traversal Limits → -
Expert - Security and Production Architecture
Access methods and record users, tenant boundaries, monitoring, and the upgrade that is a migration.
1 lesson 11 min of reading
Start with Access Methods, Tenant Boundaries, Monitoring and Upgrades → -
Capstone
One collaborative tracker, defended on tenant isolation, live query convergence and a timed rebuild.
1 lesson 10 min of reading
Start with Capstone - Collaborative Project Tracker →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- Docker, and SurrealDB 2.x with a file-backed store
- Node.js or Python with the matching SurrealDB SDK
- A project tracker dataset generator you write
- The programme's shared foundations; a document and a graph database course help
Common questions
- What does the SurrealDB: Multi-Model Records, Graph Links and Live Queries course cover?
- It is 5 levels and 7 lessons: Beginner - Foundations; Intermediate - Application Behaviour; Advanced - Performance and Reliability; Expert - Security and Production Architecture; Capstone. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 63 minutes of reading and exercises - roughly 1.1 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- Docker, and SurrealDB 2.x with a file-backed store. Node.js or Python with the matching SurrealDB SDK. A project tracker dataset generator you write. The programme's shared foundations; a document and a graph database course help.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Explain namespaces, databases, tables, records and record identifiers. Write SurrealQL for CRUD, filtering, aggregation and nested data. Use record links and explain how they differ from joins. Create graph edges with RELATE and traverse them in both directions. Choose between schemafull and schemaless tables with reasons. Define fields, types, assertions and indexes, and verify they are enforced. Choose a storage backend and state what it determines. Use transactions, and verify their actual behaviour on your version. Define functions and events, and explain when an event fires. Implement record-level permissions and test every denial. Build a live query subscription and handle the reconnection problem. Design full-text and vector search with analyzers and indexes. Read query plans where available and design indexes from evidence. Set and justify traversal limits. Export and import, and measure both. Plan recovery for your storage backend, including rebuild. Plan an upgrade as a rehearsed migration. Produce a deployment, tenancy and cost checklist.