UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Class Definitions
  • Object Properties
  • Data Properties
  • Using Ontology Labels
  • Validation & Enforcement
  1. Docs
  2. /
  3. Ontology
  4. /
  5. Introduction

Introduction

GQLDB supports ontology features that bring semantic web capabilities to your graph database. This allows you to define classes, properties with domain/range constraints, and enable inference based on class hierarchies.

Key Concepts

  • Classes: Define node labels with hierarchy, exclusivity, or inference.
  • Object Properties: Define edge labels with domain / range constraints and other features.
  • Data Properties: Define typed properties on nodes with XSD types.
  • Prefixes: Shorthand for IRI namespaces (like foaf: for FOAF vocabulary).

LPG vs Ontology Graph

FeatureLPG (Labeled Property Graph)Ontology Graph
IdentityLocal identifierGlobal IRI (foaf, ex), see Loading Prefixes
Node labelsFree-form labelsOntology class labels (@prefix:Class), see Class Definitions
Edge labelsFree-form labelsObject properties, see Object Properties
Node attributesFree-form key / valueData properties with XSD-typed values, see Data Properties
Edge attributesFree-form key / valueNone
SchemaOptional (open graph) or defined (closed graph)Class and property definitions
InferenceNoneSubclass inference, property characteristics

Creating Ontology Graphs

Create a graph with ontology support enabled:

GQL
CREATE GRAPH myOntology WITH ONTOLOGY

Loading Prefixes

A prefix is a short alias for a long IRI (Internationalized Resource Identifier). Ontology terms are identified by full IRIs, a prefix lets you write a short name instead.

For example, after loading foaf as an alias for http://xmlns.com/foaf/0.1/, the term <http://xmlns.com/foaf/0.1/Person> can be written as the ontology label @foaf:Person in GQL graph patterns.

Load common vocabularies:

GQL
LOAD PREFIX foaf FROM 'http://xmlns.com/foaf/0.1/'
LOAD PREFIX ex FROM 'http://example.org/'
LOAD PREFIX rdfs FROM 'http://www.w3.org/2000/01/rdf-schema#'

-- The FROM clause also accepts an IRI literal (angle-bracketed) instead of a quoted string
LOAD PREFIX foaf FROM <http://xmlns.com/foaf/0.1/>

A few things follow from this:

  • Prefixes are per-graph state. After creating an ontology graph, you start with no prefixes loaded.
  • The prefix is just your local nickname for the full IRI. LOAD PREFIX bigbird FROM 'http://xmlns.com/foaf/0.1/' works, and @bigbird:Person then means the same FOAF Person that @foaf:Person would. By convention, reuse the community-standard names (foaf, rdfs, schema, ex).
  • Identity is by full IRI, not by short name. FOAF's Person (http://xmlns.com/foaf/0.1/Person) and Schema.org's Person (http://schema.org/Person) are distinct classes in the database even though both spell their local name "Person" — the prefix is what keeps them apart. A single node can be tagged as both without contradiction.

Load all built-in standard prefixes (foaf, rdf, rdfs, owl, xsd, etc.):

GQL
LOAD ALL PREFIX

To bulk-load every prefix declared in an RDF document at a URL or file path:

GQL
LOAD PREFIX ALL FROM 'http://xmlns.com/foaf/spec/index.rdf'
LOAD PREFIX ALL FROM <http://xmlns.com/foaf/spec/index.rdf>
LOAD PREFIX ALL FROM 'file:///srv/onto/foaf.ttl'

View loaded prefixes:

GQL
SHOW PREFIX

Drop a prefix:

GQL
DROP PREFIX foaf

After dropping a prefix, ontology labels that referenced it (@foaf:Person, etc.) no longer resolve at parse time and queries using the short form fail. Any nodes / edges already stored under the prefix's full IRIs remain in the graph (the database stores IRIs, not the short name); re-LOAD PREFIX foaf FROM '…' to address them by short form again.

Loading External Ontologies

An external ontology is a vocabulary file authored outside of GQLDB, typically published by a standards body or community containing class hierarchies, property definitions, prefix declarations, and constraints in a serialization like OWL, Turtle, RDF/XML, or JSON-LD. Common examples include FOAF (people and social relations), Schema.org (web-structured-data terms used by Google), SKOS (concept schemes), Dublin Core (metadata terms), and PROV-O (provenance).

LOAD ONTOLOGY reads such a file and registers everything inside in one shot, saving you from defining classes and properties for each term by hand. The file path is resolved by the GQLDB server: the file must exist on the server's filesystem (and the GQLDB process must have read permission). Loading from a server-local file is the most reliable form as it avoids network and TLS variability.

Load from a file on the GQLDB server, format auto-detected from the .ttl extension:

GQL
LOAD ONTOLOGY FROM 'file:///path/on/server/foaf.ttl'

The loader auto-detects from the file extension (.ttl → TURTLE, .owl/.rdf/.xml → RDFXML, .nt → NTriples). Pass FORMAT explicitly only when auto-detection would guess wrong (e.g. a .txt file containing Turtle, or a server that returns a generic content type):

GQL
LOAD ONTOLOGY FROM 'file:///srv/onto/data.txt' FORMAT TURTLE

Supported FORMAT keywords: OWL, TURTLE, RDFXML, JSONLD.

VERBOSE surfaces parser warnings (unknown constructs, malformed triples) in the result message, useful when integrating a new ontology to surface silent compatibility issues:

GQL
LOAD ONTOLOGY FROM 'file:///srv/onto/foaf.ttl' VERBOSE

FORMAT and VERBOSE can be combined, but FORMAT must come first:

GQL
LOAD ONTOLOGY FROM 'file:///srv/onto/data.txt' FORMAT TURTLE VERBOSE

Loading from a URL is also supported. For https:// URLs the host's TLS certificate must be trusted by the system trust store; plain http:// skips TLS entirely. When FORMAT is omitted, the loader checks the response Content-Type header first, then the URL's file extension, and falls back to RDFXML if neither gives a hint.

GQL
LOAD ONTOLOGY FROM 'https://schema.org/version/latest/schemaorg-current-https.rdf'
NOTE

If a URL fetch fails with a TLS error, download the file once onto the GQLDB server and load.

Viewing Ontologies

GQL
SHOW ONTOLOGY

Example output:

nameiriclassesobjectPropertiesdataProperties
FOAFhttp://xmlns.com/foaf/0.1/142519
localurn:local:myOntology312

It lists every ontology in the current graph with summary counts. It covers both imports and inline definitions:

  • One row per LOAD ONTOLOGY import, named after the source IRI.
  • The local row is added if you've created any classes or properties inline (CREATE CLASS, CREATE OBJECT PROPERTY, CREATE DATA PROPERTY) instead of importing them. It groups all your inline definitions under one synthetic ontology.

Related SHOW statements for finer views:

StatementReturns
SHOW PREFIXLoaded prefix → IRI mappings
SHOW CLASSESEvery class, with localName, superClasses, label
SHOW PROPERTIESEvery object/data property, with localName, type, domain, range, characteristics