Base level components
Data / Knowledge library
SurrealDB
records graph relationships and surrealql
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.
- Define a small table and sample records.
- Link records with a relationship.
- Query records and their connections.
- Configure and test record access rules.
- Test invalid input under the selected schema mode.
Documentation and sources
- Official project documentation (surrealdb.com)
Catalog research notes
- Research snapshot: September 9, 2026. This entry summarizes the linked primary documentation; it does not assert a latest release version.
Connect the ideas
Alternatives
Explore next
Real World Example
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.
- Define schema-full tables for Suppliers and Components to enforce data integrity.
- Create records for each entity representing a specific manufacturer or part.
- Establish graph edges between records using the RELATE statement to represent supply dependencies.
- Execute a single SurrealQL query using arrow syntax to traverse the graph from a finished product to its raw material origins.
- Utilize ACID transactions to ensure that updates to supplier status and component relationships commit atomically.
Nodes represent entities, and edges represent the flow of components between them.
Intermediate parts
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.
-- 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.