Skip to main content
The Worlds Platform utilizes the Resource Description Framework (RDF) for its core data model and SPARQL for structured querying.

RDF blob handling

The system manages RDF data through several core utilities:
  • N3 utility: Provides functions to convert between RDF blobs (e.g., N-Quads strings) and in-memory N3 stores.
  • SPARQL utility: Executes SPARQL queries using the Comunica engine over an N3 store.
    Comunica is a highly modular, open-source SPARQL query engine built for the web. It is flexible and handles large RDF data sources efficiently.

RDF patching

Centralized in the core patch service, the system processes mutations for the world database:
  1. Deterministic identification: Skolemizes and hashes each quad to a unique triple ID.
  2. Relational storage: Upserts the resulting triples into the triples table.
  3. Semantic indexing: Chunks and embeds literal values for hybrid search.
  4. Triggers: SQL triggers synchronize rdf:type relations to the entity_types table.

SPARQL execution pipeline

When you execute a SPARQL query via the API, the system follows this pipeline:
  1. Loads the world metadata from the main database.
  2. Resolves the world-specific database client via databaseManager.get(worldId).
  3. Executes handlePatch with a handler that applies updates to the world client.
    worldId
    string
    required
    The specific World ID to target for the patch context.
    patch
    Quad[]
    required
    The array of RDF Quads representing the changes to be applied.
  4. Executes the SPARQL query over the resulting RDF blob.
  5. Updates the world metadata in the main database if the blob changed during a SPARQL update.