VOS vs Commercial Edition Features

The following Guide presents collection of Virtuoso VOS/Commercial Edition Supported Features examples usage and hints.

Simple SPARQL based Data Integration Example

The following example showcase the combined effects of:

The vCard Address Book Dataset

Assume the following Address Book data constructed using terms from the vCard vocabulary:


<#vcardRick> 
<http://www.w3.org/2006/vcard/ns#given-name> "Richard" ;
<http://www.w3.org/2006/vcard/ns#family-name> "Mutt" ; 
<http://www.w3.org/2006/vcard/ns#email> <mailto:rick@selavy.org>. 

<#vcardAl>   
<http://www.w3.org/2006/vcard/ns#given-name> "Alan" ;
<http://www.w3.org/2006/vcard/ns#family-name> "Smithee" ; 
<http://www.w3.org/2006/vcard/ns#email> <mailto:alan@paramount.com>. 

The FOAF Address Book Dataset

Assume the following Address Book data constructed using terms from the FOAF vocabulary:


<#foafBill>   
<http://xmlns.com/foaf/0.1/givenName> "Billy" ;
<http://xmlns.com/foaf/0.1/familyName> "Shears" ; 
<http://xmlns.com/foaf/0.1/mbox> <mailto:bill@northernsongs.org>. 

<#foafNate> 
<http://xmlns.com/foaf/0.1/givenName> "Nanker" ;
<http://xmlns.com/foaf/0.1/familyName> "Phelge" ;
<http://xmlns.com/foaf/0.1/mbox> <mailto:nate@abkco.com>. 

Define the Problem

In the data management realm, data definition eternally varies across designers, applications, and systems in general. In this simple example we have two Address Books containing the same data, but modeled using two different vocabularies (i.e., vCard and FOAF). This kind of "data definition-induced disparity" makes accurate data access, integration, and dissemination unnecessarily difficult, and serves as a powerful (albeit often unintentional) generator of data silos.

The Solution

We can work around this by using the expressive power of SPARQL to declaratively exploit entity relationship model-based data structure and machine-readable entity relationship semantics, as delivered by RDF. Basically, our query expressions will deliver identical query results, using properties from either ontology.

How It's Done

Simply, we create an additional dataset, that holds mappings between the properties defined by the two vocabularies, vCard and FOAF.

Step 1.: vCard to FOAF Mapping Dataset

Step 2 Load Data

Step 2.1: Loading Data from Turtle Files using SPARQL 1.1 LOAD Command

SPARQL 1.1 offers a LOAD command that provides an alternative to SPARQL 1.1 INSERT with regards to data load operations. For this guide, the steps would be as follows:

  1. Copy and paste the Turtle content for each data source above into its own file, and save with an obvious name to a network accessible directory/folder, e.g., vcard_addressbook.ttl, foaf_addressbook.ttl, and vcard_foaf_mappings.ttl.
  2. Open a Virtuoso SPARQL interface using /sparql-auth or /sparql-oauth or /sparql-webid -- each of which will provide authenticated access to Virtuoso's RDF store using an identity associated with DBMS operation privileges .
  3. Execute the SPARQL 1.1 LOAD command for each file using the pattern:

    LOAD <turtle-document-URL> INTO <named-graph-IRI>

  4. Example of these hyperlinks (URLs) denote the Turtle documents created in Kingsley's personal data space:
  5. The actual LOAD commands are:

    LOAD <http://../vcard_addressbook.ttl> INTO <urn:sparql:fed:demo:vcard:addressbook> LOAD <http://../foaf_addressbook.ttl> INTO <urn:sparql:fed:demo:foaf:addressbook> LOAD <http://../vcard_foaf_mapping.ttl> INTO <urn:sparql:fed:demo:terms:mapping>

Step 2.2: Loading Data into a Virtuoso RDF Store/DBMS via INSERT commands

Example usage of Virtuoso's SPASQL (SQL+SPARQL hybrid language) and SPARQL 1.1's INSERT Language:

  1. SPASQL
    • Load data to create the vCard-based Address Book Data Object:

      SPASQL INSERT INTO GRAPH <urn:sparql:fed:demo:vcard:addressbook> { <#vcardRick> <http://www.w3.org/2006/vcard/ns#given-name> "Richard" ; <http://www.w3.org/2006/vcard/ns#family-name> "Mutt" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:rick@selavy.org>. <#vcardAl> <http://www.w3.org/2006/vcard/ns#given-name> "Alan" ; <http://www.w3.org/2006/vcard/ns#family-name> "Smithee" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:alan@paramount.com>. }

    • Load data to create the FOAF-based Address Book Data Object:

      INSERT INTO GRAPH <urn:sparql:fed:demo:foaf:addressbook> { <#foafBill> <http://xmlns.com/foaf/0.1/givenName> "Billy" ; <http://xmlns.com/foaf/0.1/familyName> "Shears" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@northernsongs.org>. <#foafNate> <http://xmlns.com/foaf/0.1/givenName> "Nanker" ; <http://xmlns.com/foaf/0.1/familyName> "Phelge" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:nate@abkco.com>. }

    • Load data to create the OWL-based vCard-to-FOAF mapping Data Object:

      INSERT INTO GRAPH <urn:sparql:fed:demo:terms:mapping> { <http://xmlns.com/foaf/0.1/givenName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#given-name> . <http://xmlns.com/foaf/0.1/familyName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#family-name> . <http://xmlns.com/foaf/0.1/mbox> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#email>. }

  2. SPARQL 1.1
    • Load data to create the vCard-based Address Book Data Object:

      INSERT { GRAPH <urn:sparql:fed:demo:vcard:addressbook> { <#vcardRick> <http://www.w3.org/2006/vcard/ns#given-name> "Richard" ; <http://www.w3.org/2006/vcard/ns#family-name> "Mutt" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:rick@selavy.org>. <#vcardAl> <http://www.w3.org/2006/vcard/ns#given-name> "Alan" ; <http://www.w3.org/2006/vcard/ns#family-name> "Smithee" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:alan@paramount.com>. } }

    • Load data to create the FOAF-based Address Book Data Object:

      INSERT { GRAPH <urn:sparql:fed:demo:foaf:addressbook> { <#foafBill> <http://xmlns.com/foaf/0.1/givenName> "Billy" ; <http://xmlns.com/foaf/0.1/familyName> "Shears" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@northernsongs.org>. <#foafNate> <http://xmlns.com/foaf/0.1/givenName> "Nanker" ; <http://xmlns.com/foaf/0.1/familyName> "Phelge" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:nate@abkco.com>. } }

    • Load data to create the OWL-based vCard-to-FOAF mapping Data Object:

      INSERT { GRAPH <urn:sparql:fed:demo:terms:mapping> { <http://xmlns.com/foaf/0.1/givenName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#given-name> . <http://xmlns.com/foaf/0.1/familyName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#family-name> . <http://xmlns.com/foaf/0.1/mbox> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#email>. } }

Step 3.: Verify Data

Irrespective of the method used to load data into your Virtuoso (or any other SPARQL compliant RDF store/database), you should verify the load was successful using the following commands:

  1. vCard-based Address Book:

    SELECT * FROM <urn:sparql:fed:demo:vcard:addressbook> WHERE {?s ?p ?o}

  2. FOAF-based Address Book:

    SELECT * FROM <urn:sparql:fed:demo:foaf:addressbook> WHERE {?s ?p ?o}

  3. vCard-to-FOAF mappings:

    SELECT * FROM <urn:sparql:fed:demo:terms:mapping> WHERE {?s ?p ?o}

Step 3.:Setting Up Inference Context

Virtuoso requires the use of a SQL command to associate an Ontology with an Inference Rule. Once this association is in place, you simply use the Virtuoso SPARQL processor's pragma feature to conditionally invoke reasoning based on the rules you want.

For this exercise, we'll create the rule "vcardTofoaf" by executing the following command using Virtuoso's SQL processor via command-line or HTML variants of iSQL:


rdfs_rule_set ('vcardTofoaf','urn:sparql:fed:demo:terms:mapping')

Step 4.: SPARQL Queries Demonstrating Problem Solution

  1. Reasoning Disabled:

    PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?email ?fn ?ln FROM <urn:sparql:fed:demo:foaf:addressbook> FROM <urn:sparql:fed:demo:vcard:addressbook> WHERE { ?s foaf:firstName ?fn ; foaf:lastName ?ln ; foaf:email ?email . }

  2. Inference Context Enabled:

    ## Reasoning Enabled ## DEFINE input:inference "vcardTofoaf" PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?s ?ln ?fn ?email FROM <urn:sparql:fed:demo:foaf:addressbook> FROM <urn:sparql:fed:demo:vcard:addressbook> WHERE { ?s foaf:familyName ?ln ; foaf:givenName ?fn ; foaf:mbox ?email . }

  3. Inline Inference using Property Paths: As an alternative to using the Virtuoso reasoner, and more cross SPARQL 1.1 compliant RDF store/dbms compatible, you can apply the vCard to FOAF ontology mappings inline -- courtesy SPARQL 1.1 property paths based query patterns:

    ## Property Paths Query based mapping between vCard and FOAF ## ## where "*" operator is used to deliver a magic predicate for inline mapping of ## ## key FOAF ontology properties (givenName, familyName, and mbox) to vCard ontology properties. ## SELECT ?email ?fn ?ln WHERE { <http://xmlns.com/foaf/0.1/givenName> <http://www.w3.org/2002/07/owl#equivalentProperty>* ?given_nameProp . <http://xmlns.com/foaf/0.1/familyName> <http://www.w3.org/2002/07/owl#equivalentProperty>* ?last_nameProp . <http://xmlns.com/foaf/0.1/mbox> <http://www.w3.org/2002/07/owl#equivalentProperty>* ?emailProp . ?s ?given_nameProp ?fn ; ?last_nameProp ?ln ; ?emailProp ?email . } LIMIT 10

Import an existing ontology (OWL/RDF)?

Use one of these:

  1. Virtuoso Sponger
  2. SPARQL LOAD -- via Conductor, iSQL, or /sparql-auth (which authenticates against SQL accounts) or /sparql-webid (on ssl port) for WebID? ACL based authentication

Links

Connect two or more databases (Oracle, Informix, Postgres)?

Using the VDB layer via Conductor or ATTACH statement via SQL.

Links

  1. http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtLinkRemoteTables?
  2. Linked Data Views

Create merged/unified classes?

So for example, Person object from Oracle database A, and Person object from Informix database B should be able to be unified.

Based on the above, you simply add triples to a TBox triples oriented named graph. Example:


<PersonEntityFromOracleURI>   a foaf:Person .
<PersonEntityFromInformixURI> a foaf:Person .

Map the ontology classes to DB classes?

Just more TBox triples, for example:


<ClassGeneratedFromDBMSURI>    owl:equivalentClass    <SomeClassFromAnOntologyURI> .
<ClassGeneratedFromDBMSURI>    rdfs:subClassOf        <SomeClassFromAnOntologyURI> .
<PropertyGeneratedFromDBMSURI> owl:equivalentProperty <SomePropertyFromAnOntologyURI> .
<PropertyGeneratedFromDBMSURI> rdfs:subPropertyOf     <SomePropertyFromAnOntologyURI> .

Add conditions mapping?

For example, in a table, if a column is 1, the row represents a student, but if it's 2, the row represents a faculty member. As this part of the R2RML or Native Linked Data Views declarations and it is in SPASQL, you can leverage CASE WHEN etc..

Get data from web services and apply the same mapping to these services?

This requires the Sponger Middleware component. If we don't have a cartridge in place, then a custom cartridge can be developed.

Links

  1. Virtuoso Public instance of the Sponger
  2. How the sponger middleware runs

Provide RDF's to external systems?

You have the following options:

  1. SPARQL endpoint -- for systems that support SPARQL-FED or capable of de-referencing a SPARQL Protocol URL
  2. Saving Query output to a local or network drive -- you can even leverage the ability to save SPARQL Query Results to an HTTP accessible WebDAV folder (once enabled via the conductor).

Related