Session 13 of Going Meta (broadcast February 9, 2023) explores a powerful pattern for working with data that lives outside Neo4j: instead of physically moving records into the graph database, you define virtual graphs that pull data from an external PostgreSQL time-series store on demand using APOC’s dynamic virtual resource API. The session then shows how to serialize the resulting hybrid query results as RDF through the Neosemantics HTTP endpoint.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.
Watch Recording
Full session recording on YouTube
Source Code
Cypher scripts and Python data generator
Overview
| Broadcast | February 9, 2023 |
| Tags | SQL APOC RDF Python |
| Key procedures | apoc.dv.catalog.add, apoc.dv.query, apoc.dv.queryAndLink |
What You Will Learn
- Loading a network topology dataset (devices and links) into Neo4j from CSV
- Defining APOC dynamic virtual resources (
apoc.dv.catalog.add) that proxy JDBC queries - Querying external time-series data at runtime with
apoc.dv.queryand fusing results with Cypher - Materialising virtual relationships between graph nodes and live records with
apoc.dv.queryAndLink - Generating synthetic telemetry data from Python to populate the external SQL database
- Serialising hybrid query results as RDF via the Neosemantics Cypher endpoint
Architecture
The topology graph (devices, links, geographic positions) lives in Neo4j. Telemetry readings live in a PostgreSQLsensor_telemetry table. APOC virtual resources act as the bridge: they hold the JDBC connection string and parameterised SQL query, and are invoked at query time from Cypher so no data is duplicated.
Step-by-Step Walkthrough
Load the network topology
Import devices and links from CSV, then set an integer
external_id on each device to match the primary key used in the time-series database.Register virtual resources in the APOC catalog
Each virtual resource definition stores the JDBC URL, result labels, and a parameterised SQL query. Parameters like
$deviceid are passed at query time from Cypher.Virtual resource definitions are stored in the APOC catalog and persist across sessions. You only need to register them once per database.
Query external data and aggregate in Cypher
Combine graph properties (location, device code) with aggregated telemetry fetched on demand from the SQL store — all in a single Cypher statement.
Materialise virtual relationships with queryAndLink
apoc.dv.queryAndLink fetches the external data rows and attaches them to the graph node as virtual relationships, returning a traversable path without persisting anything to disk.Register an aggregating virtual resource
A more sophisticated virtual resource computes aggregations inside PostgreSQL, reducing the data transferred to Neo4j.
Generating Synthetic Telemetry (Python)
The session uses a Python script to continuously populate thesensor_telemetry PostgreSQL table with random readings across 14 devices and 6 metric types, simulating a live network monitoring environment.
Key Concepts
Virtual graphs — Data is never moved into Neo4j. Instead, APOC catalog entries act as named, parameterised proxies for external queries. The graph database retains only the structural topology, while all metric values remain in the time-series store. Hybrid queries — Because APOC virtual resources integrate with standard Cypher, you can combine graph traversal (MATCH, WHERE, path patterns) with live external lookups (apoc.dv.query) in a single query — no middleware required.
RDF serialisation — Neosemantics can serialise any Cypher result as RDF on the fly. Combined with virtual graphs, this means you can expose live telemetry data as Linked Data without a permanent RDF store.
APOC virtual resources require APOC Enterprise or APOC Extended. Check the APOC documentation for the
apoc.dv.* procedure availability in your Neo4j version.Resources
APOC Virtual Resources
APOC documentation for dynamic virtual resources
Neosemantics (n10s)
RDF and Linked Data integration for Neo4j
R2RML Standard
W3C mapping language for relational databases to RDF
psycopg2 Docs
PostgreSQL adapter for Python