Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jbarrasa/goingmeta/llms.txt

Use this file to discover all available pages before exploring further.

Session 19 of Going Meta, broadcast on August 1, 2023, addresses a real-world challenge for ontology engineers: how do you track and compare changes between successive versions of an OWL ontology? Jesus Barrasa demonstrates an approach built entirely on Neo4j Enterprise — one database per ontology version, a composite database to span them all, and Cypher USE clauses to compute diffs between versions. The resulting change sets are visualised in a live NeoDash dashboard.

What You’ll Learn

  • How to create separate Neo4j databases for each ontology version
  • How to configure neosemantics (n10s) consistently across all version databases
  • How to create a composite database with version aliases
  • How to compute added and removed classes between versions using cross-database Cypher calls
  • How to use a NeoDash dashboard to browse the change history visually

Architecture Overview

One Database per Version

Each ontology version (v0, v1, v2) lives in its own Neo4j database, imported with neosemantics. This keeps versions isolated and queryable independently.

Composite Database for Diffing

A Neo4j composite database (ontos) with aliased targets (ontos.v0, ontos.v1, ontos.v2) allows cross-version Cypher queries using USE subqueries.

Step-by-Step Walkthrough

1

Create databases for each ontology version

Create one database per version and configure each for RDF import, enabling multi-valued properties and language tag retention:
CREATE DATABASE ontov0;
:USE ontov0;
CREATE CONSTRAINT n10s_unique_uri FOR (r:Resource) REQUIRE r.uri IS UNIQUE;
CALL n10s.graphconfig.init({
  handleMultival: "ARRAY",
  multivalPropList: [
    'http://www.w3.org/2000/01/rdf-schema#label',
    'http://www.w3.org/2000/01/rdf-schema#comment'
  ],
  keepLangTag: true
});

CREATE DATABASE ontov1;
:USE ontov1;
CREATE CONSTRAINT n10s_unique_uri FOR (r:Resource) REQUIRE r.uri IS UNIQUE;
CALL n10s.graphconfig.init({
  handleMultival: "ARRAY",
  multivalPropList: [
    'http://www.w3.org/2000/01/rdf-schema#label',
    'http://www.w3.org/2000/01/rdf-schema#comment'
  ],
  keepLangTag: true
});

CREATE DATABASE ontov2;
:USE ontov2;
CREATE CONSTRAINT n10s_unique_uri FOR (r:Resource) REQUIRE r.uri IS UNIQUE;
CALL n10s.graphconfig.init({
  handleMultival: "ARRAY",
  multivalPropList: [
    'http://www.w3.org/2000/01/rdf-schema#label',
    'http://www.w3.org/2000/01/rdf-schema#comment'
  ],
  keepLangTag: true
});
handleMultival: "ARRAY" is essential for rdfs:label and rdfs:comment, which commonly appear once per language in an OWL ontology. Without it, only one language tag would be retained.
2

Create a composite database with version aliases

Group all version databases under a single composite database so they can be queried together:
CREATE COMPOSITE DATABASE ontos;
CREATE ALIAS ontos.v0 FOR DATABASE ontov0;
CREATE ALIAS ontos.v1 FOR DATABASE ontov1;
CREATE ALIAS ontos.v2 FOR DATABASE ontov2;

SHOW DATABASES;
3

Import ontology versions using the Python notebook

Use the session19/versioning_ontos.ipynb Python notebook to load each version of the OWL ontology into its respective database. The notebook uses neosemantics to fetch the ontology files (created in Protégé) and imports them into ontov0, ontov1, and ontov2.
4

Compute the diff between two versions

Switch to the composite database and use CALL { USE … } subqueries to collect classes from each version, then calculate what was added in v1 that wasn’t in v0:
:USE ontos

CALL {
  USE ontos.v0
  MATCH (c0:owl__Class)
  RETURN collect(c0.uri) AS v0_class_uris
} WITH v0_class_uris
CALL {
  USE ontos.v1
  MATCH (c1:owl__Class)
  RETURN collect(c1.uri) AS v1_class_uris
}
UNWIND [x IN v1_class_uris WHERE NOT x IN v0_class_uris] AS new_class
RETURN new_class
Reverse the filter (NOT x IN v1_class_uris) to find classes that were removed between v0 and v1. The same pattern works for owl__ObjectProperty and owl__DatatypeProperty nodes.
5

Visualise changes in NeoDash

Load the NeoDash dashboard included in session19/dashboard/ to browse the three ontology versions side-by-side and explore added/removed classes interactively.

Key Concepts

Composite Databases

Neo4j Enterprise’s composite databases are the backbone of this approach, enabling a single Cypher query to span multiple isolated graph databases.

USE Subqueries

CALL { USE db.alias … } subqueries let you collect data from each version database and join the results in the outer query — the foundation of the diff calculation.

Protégé Integration

Ontology versions are authored in Protégé and exported as OWL/Turtle files, then loaded into Neo4j via neosemantics — a realistic enterprise workflow.

NeoDash Visualisation

The session includes a ready-made NeoDash dashboard that renders the version diff as an interactive graph, making ontology changes visible to non-technical stakeholders.

Resources

Watch the Recording

Full session recording on YouTube — August 1, 2023.

Session Code

CQL scripts, Python notebook, and NeoDash dashboard on GitHub.

Build docs developers (and LLMs) love