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. Please reply to this post if you need to work with the Open Source Edition, as that will require different VADs.)

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  ) 
    FROM <> 
    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"""" ];


  • 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 
      ( 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


1 Like