UltipaDocs
Try Playground
  • Overview
  • Class Definitions
  • Property Definitions
  • Using Ontology Labels
  • Validation & Enforcement
  1. Docs
  2. /
  3. Ontology
  4. /
  5. Overview

Ontology

Overview

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 types for nodes with inheritance (EXTENDS) and exclusivity (DISJOINT)
  • Object Properties - Define edge types with domain/range constraints and characteristics (SYMMETRIC, TRANSITIVE)
  • Data Properties - Define typed properties on nodes with XSD types
  • Prefixes - Shorthand for IRI namespaces (like foaf: for FOAF vocabulary)
  • Inference - Automatic classification based on class hierarchies

LPG vs Ontology Graph

FeatureLPG (Labeled Property Graph)Ontology Graph
Node labelsFree-form labelsOntology class labels (@prefix:Class)
Edge typesFree-form typesObject properties with domain/range
SchemaOptional (open graph) or defined (closed graph)Class and property definitions
InferenceNoneSubclass inference, property characteristics
ValidationType checking onlyDomain, range, cardinality, disjoint checks

Creating an Ontology Graph

Create a graph with ontology support enabled:

GQL
CREATE GRAPH my_ontology_graph ONTOLOGY

Loading Prefixes

Prefixes provide shorthand for IRI namespaces. Load common vocabularies:

GQL
// Load common prefixes
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#'

View loaded prefixes:

GQL
SHOW PREFIXES
prefixiri
foafhttp://xmlns.com/foaf/0.1/
exhttp://example.org/
rdfshttp://www.w3.org/2000/01/rdf-schema#

Loading External Ontologies

Import ontology definitions from OWL/RDF files:

GQL
// Load FOAF ontology from URL
LOAD ONTOLOGY FROM 'http://xmlns.com/foaf/spec/index.rdf'
GQL
// Load from local file
LOAD ONTOLOGY FROM 'file:///path/to/my-ontology.owl'
GQL
// Load with specific format
LOAD ONTOLOGY FROM 'http://example.org/onto.ttl' FORMAT 'turtle'

Viewing Ontology Information

View defined classes:

GQL
SHOW CLASSES
classsuperclassdescription
@foaf:Person@foaf:AgentA person
@foaf:Organization@foaf:AgentAn organization
@ex:Employee@foaf:PersonAn employee

View defined properties:

GQL
SHOW PROPERTIES
propertytypedomainrangecharacteristics
@foaf:knowsOBJECT@foaf:Person@foaf:PersonSYMMETRIC
@ex:worksForOBJECT@foaf:Person@foaf:Organization
@foaf:nameDATA@foaf:Agentxsd:string

See the following pages for detailed information:

  • Class Definitions
  • Property Definitions
  • Using Ontology Labels
  • Validation & Enforcement