Generating Virtuoso RDF Views using R2RML

This guide walks you through the process of generating RDF Views over Relational Tables using an interaction flow enabled by the Virtuoso R2RML Wizard.

This functionality is delivered via the Virtuoso add-on module referred to as the R2RML Processor VAD package. You will also need to install the latest build of the Virtuoso Conductor VAD. (Note: *These VAD links and the documentation below are for Virtuoso Enterprise Edition v8.3. If you need to work with the Virtuoso Open Source Edition this requires these R2RML and Conductor open source specific VADs. Note also that the open source edition can only generate RDF Views of local tables within Virtuoso, as it does not support the Virtual data engine for accessing remote tables.)

Before You Start

Confirm that your target relational tables or views, whether managed by your local Virtuoso instance or a remote ODBC- or JDBC-accessible DBMS, are both available and accessible. This can be achieved using Virtuoso’s iSQL command-line interface, the Conductor Admin Interface, or the SPASQL Query Builder interface, as demonstrate by the steps that follow.

SPASQL Query Builder Usage Example

Login using “vdb” for both username and password, and then interact with the relational tables or views from which you’ll generate RDF Views.

Catalog Interaction

Basic SQL Query

Generate RDF Views using the Virtuoso R2RML Wizard

  1. Load an R2RML Mapping Document to Virtuoso using the R2RML Wizard user interface. Note: The Target Graph IRI field value is an IRI that denotes a Named Graph IRI associated with the R2RML-based mapping descriptions.

  2. Validate the R2RML statements for both syntax and data reference integrity

  3. Generate and review Virtuoso-native RDB-to-RDF mapping definitions (a/k/a quad mapping definitions) from R2RML

  4. Generate RDF Views

  5. Review the RDF Views that have been generated, by inspecting the http://{CNAME}/sparql/rdfviews.vsp service exposed by your SPARQL Endpoint. You can click here to see a live example hosted in our live Virtuoso demo instance.

  6. Test RDF Views using a simple SPARQL SELECT Query scoped to a Named Graph associated with the newly generated RDF View Definition; for example, the following —

    SELECT ( SAMPLE ( ?s ) AS ?sample ) 
           (  COUNT ( 1 )  AS ?count  ) 
                              ?o
    FROM <http://demo.openlinksw.com/NorthwindQA#> 
    WHERE { ?s a ?o }
    GROUP BY ?o
    ORDER BY DESC ( ?count )
    LIMIT 50
    

    — which delivers the following page of query results —

    You can see live query results displayed here, again from our live Virtuoso demo instance.

With the newly generated RDF Views in place, you can leverage Virtuoso’s unique ability to blend SQL-accessible Relational Tables and SPARQL-accessible RDF Graphs through any HTTP-, ODBC-, or JDBC-compliant application or service.

Here’s a live example page constructed using the SPASQL Query Tool. When challenged, authenticate using “vdb” for both username and password.

Click on a Hyperlink that denotes an entity of interest, and just follow-your-nose for deeper exploration, to experience the effect of Hyperlinks functioning as platform-agnostic Super Keys.

Update Existing RDF Views

To change an existing RDF View, you need only to perform the following few steps:

  1. Modify your R2RML document

  2. Validate your modified R2RML document

  3. Regenerate your RDF Views, as outlined in the previous section

Identifier Handling in R2RML Mappings

Identifier Quote Handling is an important aspect of an DBMS independent interaction endeavor. Thus, its important to understand how this is handled in regards to mappings.

ODBC & JDBC compliant Data Sources Attached to Virtuoso

As a sophisticated client that supports either open standard, Virtuoso will deduce the identifier quote character of an external target DBMS via interactions with its ODBC Driver or with its JDBC Driver using our ODBC-JDBC bridge.

Native Virtuoso Relational Tables

Double quotes (") are the native identifier quote character for Virtuoso. Referencing tables, views, or stored procedures from R2RML is supported using a variety of patterns, as in the following examples using the Categories table.

  • rr:logicalTable [ rr:tableSchema "Demo" ; rr:tableOwner "demo" ; rr:tableName "Categories" ]; — as in examples in this document
  • rr:logicalTable [ rr:tableName "\"Demo\".\"demo\".\"Categories\"" ];
  • rr:logicalTable [ rr:tableName "Demo.demo.Categories" ];
  • rr:logicalTable [ rr:tableName """"Demo"."demo"."Categories"""" ];

Glossary

  • IRI CLASS — a custom Virtuoso Data Type that provides a template-based mechanism for declaring how values from a column in a relational table are to be transformed into IRIs for denoting entities in an RDF graph, such as —

    CREATE IRI CLASS NorthwindKG:categories 
      "http://^{URIQADefaultHost}^/NorthwindKG/categories/CategoryID/%d#this" 
      ( IN _CategoryID INTEGER NOT NULL ) . ;
    
  • LITERAL CLASS — a custom Virtuoso Data Type that provides a template-based mechanism for declaring how values from a column in a relational table are to be transformed into IRIs for denoting entities in an RDF graph, such as —

    CREATE LITERAL CLASS NorthwindKG:CategoryName "%s"
      ( IN CategoryName LONG NVARCHAR ) OPTION ( LANG "en" ) ;
    
  • Quad Mappings (a/k/a RDF View Definitions) — SPASQL-based template definitions that describe how relational tables are mapped to virtual RDF graphs

  • Quad Maps (a/k/a RDF Views) — actual mapping templates for generating virtual RDF triples from relational tables

  • R2RML Document — a document comprising R2RML mappings

  • R2RML Vocabulary (a/k/a R2RML Ontology) — a collection of terms for describing how Entity Relationship Types represented as Records grouped by Tables are mapped to Entity Relationship Types grouped by RDF sentence Predicates

  • Virtual Graph — A named graph associated with virtual triples defined by one or more Quad Mappings

Sample Live Queries

Sample Files and Scripts

Related

1 Like

Hello, I am using an open source edition of virtuoso. So I require different VADs of “R2RML Processor VAD package” and “Virtuoso Conductor VAD”. Thank you very much for your reply if possible: My email address is junjun.cao@mcgill.ca. Could you please kindly send them to me?

The initial post has been updated with direct links to the Virtuoso open source specific R2RML and Conductor* specific VADs …

Hello. Thank you very much.
Are you sure this is for “open source edition” of virtuoso specially?
(Because I yesterday downloaded the packages on this site of kidehen, which packages are for Virtuoso Enterprise Edition. But I still tried installation of the Conductor package, as a result it yielded a fatal error that was the failure of logging on from conductor user interface of virtuoso. Oh my God, then I had to uninstall and reinstall virtuoso again to recover.

Of course the packages I provided for the R2RML and Conductor VADs are for open source, which is why I provided them. If you tried installing the commercial edition Conductor VAD on the open source instance then I would expect it to fail. If the VAD failed to install then all you have to do it remove the virtuoso.trx file and Virtuoso should restart in its previous working state, although you don’t say in what way and what error was reported in the “virtuoso.log” or conductor when attempting to install so I can’t comment further …

1 Like

Thank you very much. Seemingly I have already successfully installed the 2 Packages since I can see a Linked Data/R2RML tab on the user interface.

Now my question is I don’t know how to flexibly make use of Linked Data/Views or Linked Data/R2RML to convert a CSV file or a Relational Database into RDF format. By “flexibly”, I mean I hope to customize the vocabulary of the ontology. Could you please kindly help me? I would rather pay for your help. If OK, what about a zoom meeting?(junjun.cao@mcgill.ca)

I tried to figure it out through the official documentation: 16.7.3. How do I use it with Virtuoso?.
But it always failed by this step:
exec ('sparql ’ || DB.DBA.R2RML_MAKE_QM_FROM_G (‘http://temp/product’));

and prompted: *** Error 22023: [Virtuoso Driver][Virtuoso Server]SR005: Function xenc_digest needs a string or binary as argument 1, not an arg of type DB_NULL (204)

at line 5 of Top-Level:

exec ('sparql ’ || DB.DBA.R2RML_MAKE_QM_FROM_G (‘http://temp/product’))

We provide chargable consultancy services which are payable in advance. Let me if you would like to receive a quote and we can email you directly to discuss requirements and costs etc

Have you tried following the steps in this post on the generation Virtuoso RDF Views using R2RML ?

We also have other documents available on creation of RDF Linked Data Views like: