Reasoning over Virtual Database


I am evaluating Virtuoso as part of data fabric project in my organization. I found out in the documentation 16.14.1. Introduction ( that reasoning will work only for materialized graphs. But reading thought an article Harmonizing Disparate RDBMS Data using Virtuoso’s built-in Reasoning and Inference functionality - Virtuoso Universal Server / Tips, Tricks, and HowTos - OpenLink Software Community ( it seems that reasoning can be done for VDB as well. I tried a reasoning over VDB as per the documentation, but with no luck. Can you please provide some details about how reasoning can be done for VDB if possible.

Please find the snippets of my test.

Created virtual graph using Virtuoso.

Basic SPARQL query to retrieve movies works.


PREFIX : http://localhost:8890/schemas/movies_mysql/

SELECT * FROM http://localhost:8890/movies_mysql#
?s a :movies;
:title ?title .

What I wanted to test is create an RDFS class called “Films” which is equivalent as :movies using owl:equivalentClass.

For that I tried to add “Films” class in to the graph and used owl:equivalentClass


GRAPH http://localhost:8890/schemas/movies_mysql#
http://localhost:8890/schemas/movies_mysql/Films a rdfs:Class .
http://localhost:8890/schemas/movies_mysql/Films owl:equivalentClass http://localhost:8890/schemas/movies_mysql/movies .

TO http://localhost:8890/schemas/movies_mysql# ;

Then created RDFS rule


I was expecting below query would return all “movies”


DEFINE input:inference ‘mysql-vdb-test’

PREFIX : http://localhost:8890/schemas/movies_mysql/

FROM http://localhost:8890/movies_mysql#
?s a :Films;
:title ?title.

But I get empty result.

The need for physical triples to be materialized in the RDF Quad for reasoning to be performed is still a requirement for RDF Views. In the Virtuoso Conductor Linked Data Views Wizard by default when RDF Views are created they are transient ie virtual triples of the relational data that are determined at query runtime. In the Linked Data Views Wizard on the final Linked Data View definition page there is a checkbox option Enable Data Syncs with Physical Quad Store which if selected will then materialize the virtual triples to physical triples in the Quad Store with its own graph name (typically urn:... rather then http://... to distinguish them) and it is that physical graph the inference queries should be targeted against. The RDF_VIEW_SYNC_TO_PHYSICAL can also be run manually to materialize RDF Views.

Note when materalizing the RDF Views you should be aware of the size of the tables to be transformed to RDF and ensure the Virtuoso instance is configured suitably for hosting the expected number of triples (number of columns * number of rows typically).

In addition to what @hwilliams outlined, you do have the option to create Custom Inference Rules that boil down to SPARQL as the Rule Language, courtesy of terms from the SPIN Ontology.

Custom Inference Rules basically use SPARQL CONSTRUCT Queries to create Custom Relations targeting native or virtual graphs.

Here are links to how-to oriented docs regarding Custom Inference Rules:

Thank you Williams for the clarification

Thanks Kingsley for the explanation