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:
| Feature | LPG (Labeled Property Graph) | Ontology Graph |
|---|---|---|
| Node labels | Free-form labels | Ontology class labels (@prefix:Class) |
| Edge types | Free-form types | Object properties with domain/range |
| Schema | Optional (open graph) or defined (closed graph) | Class and property definitions |
| Inference | None | Subclass inference, property characteristics |
| Validation | Type checking only | Domain, range, cardinality, disjoint checks |
Create a graph with ontology support enabled:
GQLCREATE GRAPH my_ontology_graph ONTOLOGY
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:
GQLSHOW PREFIXES
| prefix | iri |
|---|---|
| foaf | http://xmlns.com/foaf/0.1/ |
| ex | http://example.org/ |
| rdfs | http://www.w3.org/2000/01/rdf-schema# |
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'
View defined classes:
GQLSHOW CLASSES
| class | superclass | description |
|---|---|---|
| @foaf:Person | @foaf:Agent | A person |
| @foaf:Organization | @foaf:Agent | An organization |
| @ex:Employee | @foaf:Person | An employee |
View defined properties:
GQLSHOW PROPERTIES
| property | type | domain | range | characteristics |
|---|---|---|---|---|
| @foaf:knows | OBJECT | @foaf:Person | @foaf:Person | SYMMETRIC |
| @ex:worksFor | OBJECT | @foaf:Person | @foaf:Organization | |
| @foaf:name | DATA | @foaf:Agent | xsd:string |
See the following pages for detailed information: