The following Guide presents collection of Virtuoso VOS/Commercial Edition Supported Features examples usage and hints.
The following example showcase the combined effects of:
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>.
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>.
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.
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.
Simply, we create an additional dataset, that holds mappings between the properties defined by the two vocabularies, vCard and FOAF.
<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>.
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:
LOAD <turtle-document-URL> INTO <named-graph-IRI>
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>
Example usage of Virtuoso's SPASQL (SQL+SPARQL hybrid language) and SPARQL 1.1's INSERT Language:
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>. }
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>. }
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>. }
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>. } }
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>. } }
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>. } }
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:
SELECT * FROM <urn:sparql:fed:demo:vcard:addressbook> WHERE {?s ?p ?o}
SELECT * FROM <urn:sparql:fed:demo:foaf:addressbook> WHERE {?s ?p ?o}
SELECT * FROM <urn:sparql:fed:demo:terms:mapping> WHERE {?s ?p ?o}
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')
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 . }
## 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 . }
## 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
Use one of these:
Using the VDB layer via Conductor or ATTACH statement via SQL.
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 .
Just more TBox triples, for example:
<ClassGeneratedFromDBMSURI> owl:equivalentClass <SomeClassFromAnOntologyURI> . <ClassGeneratedFromDBMSURI> rdfs:subClassOf <SomeClassFromAnOntologyURI> . <PropertyGeneratedFromDBMSURI> owl:equivalentProperty <SomePropertyFromAnOntologyURI> . <PropertyGeneratedFromDBMSURI> rdfs:subPropertyOf <SomePropertyFromAnOntologyURI> .
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..
This requires the Sponger Middleware component. If we don't have a cartridge in place, then a custom cartridge can be developed.
You have the following options: