Meshing Data across ODBC/JDBC Accessible Data Sources and RDF data (local and/or via SPARQL-FED)

jdbc
rdf
sparql
odbc

#1

As a multi-model RDBMS, Virtuoso enables the use of SPARQL from within SQL, courtesy of SPASQL (SPARQL and SQL fusion).

Syntax:

SELECT {SELECT-LIST}
FROM
(
	SPARQL
	{SPARQL-Query}
) AS <Alias> 

Examples

FOAF (local):

SELECT PersonInstance.webid, 
       PersonInstance.name 
FROM
  (
    SPARQL
    SELECT DISTINCT * 
    WHERE 
      { ?webid  a          foaf:Person ; 
                foaf:name  ?name .
                FILTER (isIRI(?webid)) 
                FILTER (?name != '')
                FILTER (! CONTAINS(STR(?webid),'uriburner') ) 
      } 
    LIMIT 50
  ) AS PersonInstance
WHERE name like 'B%' ;

FOAF using SPARQL-FED:

SELECT PersonInstance.webid, PersonInstance.name 
FROM
  (
    SPARQL
    SELECT DISTINCT * 
    WHERE 
      { 
        SERVICE <http://linkeddata.uriburner.com/sparql>
	  {
            SELECT DISTINCT * 
            WHERE 
              {
                ?webid  a          foaf:Person ; 
                        foaf:name  ?name .
                        FILTER (isIRI(?webid)) 
                        FILTER (?name != '')
                        FILTER (! CONTAINS(STR(?webid),'uriburner') ) 
              }
            LIMIT 50
          }
      } 
  ) AS PersonInstance ;

DBpedia:

SELECT DISTINCT DBpedia.name AS "Actor Label", 
                DBpedia.actor AS "DBpdia ID", 
                DBpedia.school AS "School ID", 
                DBpedia.schoolLabel AS "School Label"
FROM
  (
    SPARQL
    PREFIX dct: <http://purl.org/dc/terms/>
    SELECT *
    WHERE  
      {
        SERVICE <http://dbpedia.org/sparql> 
          {
            ?actor   dct:subject                              <http://dbpedia.org/resource/Category:Tony_Award_winners> ;
                     <http://dbpedia.org/ontology/almaMater>  ?school ;
                     foaf:name                                ?name .
            ?school  rdfs:label ?schoolLabel . 
            FILTER (LANG(?name) = "en")
            FILTER (LANG(?schoolLabel)= "en")
          }
      }
    ORDER BY ASC(?school)
    LIMIT 100
  ) AS DBpedia ;