knowledge/technology/applications/development/SurrealDB.md
2025-06-11 08:09:09 +02:00

1.5 KiB

obj website repo
application https://surrealdb.com https://github.com/surrealdb/surrealdb

SurrealDB

SurrealDB is a powerful, cloud-native, multi-model database built for modern application development. It supports relational, document, graph, vector, and real-time data access, all via a unified SQL-like query language called SurrealQL. There is also a GUI called Surrealist.

Multi-Model Support

  • Relational: Traditional table structure with foreign key-like linking.
  • Document: JSON-based records with schema-less flexibility.
  • Graph: Native support for linked data using edges and nodes.
  • Vector: Built-in similarity search for AI/ML use cases.
  • Real-time: Subscriptions and change feeds.
  • Time-Series & Search: Native support for time-ordered and full-text queries.

SurrealQL

SurrealQL blends the familiarity of SQL with document/graph features.

-- Create a user
CREATE user:john SET name = 'John Doe', email = 'john@example.com';

-- Read a record
SELECT * FROM user:john;

-- Create a relationship (graph)
RELATE user:john->friend->user:jane;

-- Search by text
SELECT * FROM article WHERE content CONTAINS 'database';

-- Vector similarity search
SELECT * FROM embeddings WHERE vector <-> [0.1, 0.2, 0.3] LIMIT 3;

Compose

services:
    surrealdb:
        ports:
            - 80:8000
        volumes:
            - /local-dir:/container-dir
        image: surrealdb/surrealdb:latest
        command: start --user root --pass root rocksdb:/container-dir/mydatabase.db