Skip to content
NEW BLOG

Using Surrealism to build your own extensions

Read blog

1/2

Knowledge graphs hero illustration

Knowledge graphs, natively

Ontological modeling with schema-as-ontology. Rich edges, vector search alongside structured data, and graph traversal - all in SurrealQL.

ONTOLOGICAL MODELING

Your schema is your ontology

In SurrealDB, tables define entity types and typed relations define relationship types. Your database schema maps directly to your domain ontology. No separate modeling layer, no translation between conceptual models and physical storage.

1-- Define an ontology directly in the schema
2DEFINE TABLE person SCHEMAFULL;
3DEFINE FIELD name ON person TYPE string;
4DEFINE FIELD role ON person TYPE string;
5
6DEFINE TABLE knows SCHEMAFULL TYPE RELATION FROM person TO person;
7DEFINE FIELD since ON knows TYPE datetime;
8DEFINE FIELD confidence ON knows TYPE float;
9DEFINE FIELD context ON knows TYPE string;

RICH EDGES

Relationships as documents

Edges in SurrealDB are full documents - they carry properties, timestamps, confidence scores, and metadata. Relationships are first-class citizens, not just pointers between nodes.

1-- Create a relationship with rich metadata
2RELATE person:jaime->knows->person:sarah SET
3 since = d"2020-03-15",
4 confidence = 0.95,
5 context = "worked together at Acme Corp";
6
7-- Traverse with filters on edge properties
8SELECT ->knows[WHERE confidence > 0.9]->person.name AS trusted_contacts
9FROM person:jaime;

HYBRID SEARCH

Vector search alongside structured data

Store embeddings alongside their source entities. Combine vector similarity with graph traversal and structured filters in a single SurrealQL query. Semantic relevance meets structural precision.

Co-located embeddings

Vectors live alongside the entities they represent. No separate vector store, no ID mapping, no sync jobs.

Hybrid queries

Combine cosine similarity, graph traversal, full-text search, and structured filters in one statement.

Knowledge enrichment

Use vector similarity to discover connections, then materialise them as graph edges for future traversal.

GET STARTED

Build knowledge graphs with SurrealDB

Ontological modeling, rich edges, vector search alongside structured data - all in one database.