AI Space

Data / Knowledge library

SurrealDB

records graph relationships and surrealql

Multi-model database

Why learn SurrealDB?

Useful for exploring connected application data in one system. Permissions, schema choices, and supported deployment modes require explicit validation.

Where it came from

SurrealDB combines multiple data-model features, including records and graph relationships, behind its query language and database interfaces.

Build your understanding

Work through these exercises in order. Try the task before opening a reference.

  1. Define a small table and sample records.
  2. Link records with a relationship.
  3. Query records and their connections.
  4. Configure and test record access rules.
  5. Test invalid input under the selected schema mode.

Documentation and sources

Catalog research notes

Connect the ideas

Alternatives

ArangoDB

Explore next

Neo4jMongoDBRust

Real World Example

Illustrative business scenario · AI-generated from linked documentation · Not a measured customer case study

Supply Chain Provenance Tracking

Logistics companies managing complex, multi-tier supplier networks.

The business problem

Traditional relational databases struggle to perform recursive lookups across deep supply chain dependencies, leading to slow visibility into the origin of raw materials.

How this topic solves it

SurrealDB uses a multi-model approach where supply chain entities are stored as records and their dependencies are defined as typed graph edges, allowing for single-query recursive traversal of the entire lineage.

  1. Define schema-full tables for Suppliers and Components to enforce data integrity.
  2. Create records for each entity representing a specific manufacturer or part.
  3. Establish graph edges between records using the RELATE statement to represent supply dependencies.
  4. Execute a single SurrealQL query using arrow syntax to traverse the graph from a finished product to its raw material origins.
  5. Utilize ACID transactions to ensure that updates to supplier status and component relationships commit atomically.
Supply Chain Relationship Model · Entity relationships

Nodes represent entities, and edges represent the flow of components between them.

Raw Material

Base level components

Sub-Assembly

Intermediate parts

Finished Product

Final consumer item

  • Raw Material → SUPPLIES → Sub-Assembly
  • Sub-Assembly → COMPRISES → Finished Product

Implementation example

This code demonstrates creating a typed edge between two records and then using arrow syntax to traverse the graph to retrieve upstream dependencies.

surrealql · Illustrative code; not executed or production-validated.

-- Create a relationship between a raw material and a sub-assembly
RELATE raw_material:iron -> supplies -> sub_assembly:chassis CONTENT {
    quantity: 500,
    delivery_date: '2023-10-01'
};

-- Traverse the graph to find all raw materials for a specific product
SELECT ->supplies->raw_material FROM sub_assembly:chassis;

Expected business outcome

Real-time visibility into the complete provenance of any product, enabling rapid identification of upstream bottlenecks or quality issues.

Limitations and checks

Deep recursive graph traversals can become computationally expensive as the depth of the supply chain increases; developers should monitor query execution time and consider indexing frequently traversed paths.

Sources

Generated 2026-10-18 with gemini-3.1-flash-lite. Your assessment includes two questions about this example.

Catalog source: technology-maxxing. This page reproduces the existing catalog’s learning material and source links.