Simple Virtuoso SPARQL and RDF Linked Data Views Full Text Example

sparql
linkeddata
virtuoso
rdfviews
#1

Here is a rendition of the Simple Virtuoso SQL and Full Text Example based on RDF Views generated using R2RML.

R2RML Mappings

The following statements describe how Relations represented as N-Tuples associated with a SQL-compliant RDBMS are to be mapped to Relations represented as RDF 3-Tuples (or triples) to an R2RML-processor.

RDF-Turtle-based R2RML Mapping Descriptions

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix csv: <http://demo.openlinksw.com:8890/schemas/csv/> .
@prefix csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix void: <http://rdfs.org/ns/void#> .
@prefix scovo: <http://purl.org/NET/scovo#> .
@prefix aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> .


<#TriplesMaparticles> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "csv" ; rr:tableOwner "demo" ; rr:tableName "articles" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://demo.openlinksw.com:8890/csv/articles/id/{id}#this"; rr:class csv:articles; rr:graph <http://demo.openlinksw.com:8890/csv#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:author ] ; rr:objectMap [ rr:column "author" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:companies ] ; rr:objectMap [ rr:column "companies" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:foundcbref ] ; rr:objectMap [ rr:column "foundcbref" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:foundnlpref ] ; rr:objectMap [ rr:column "foundnlpref" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:id ] ; rr:objectMap [ rr:column "id" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:image ] ; rr:objectMap [ rr:column "image" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:pdate ] ; rr:objectMap [ rr:column "pdate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:pmonth ] ; rr:objectMap [ rr:column "pmonth" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:pyear ] ; rr:objectMap [ rr:column "pyear" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:snippet ] ; rr:objectMap [ rr:column "snippet" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:source ] ; rr:objectMap [ rr:column "source" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:title ] ; rr:objectMap [ rr:column "title" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:url ] ; rr:objectMap [ rr:column "url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:snippet_id ] ; rr:objectMap [ rr:column "snippet_ID" ]; ] .

<#TriplesMapcompanies> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "csv" ; rr:tableOwner "demo" ; rr:tableName "companies" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://demo.openlinksw.com:8890/csv/companies/id/{id}#this"; rr:class csv:companies; rr:graph <http://demo.openlinksw.com:8890/csv#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:______blog_feed_url ] ; rr:objectMap [ rr:column "______blog_feed_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:blog_url ] ; rr:objectMap [ rr:column "blog_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:category_code ] ; rr:objectMap [ rr:column "category_code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:city ] ; rr:objectMap [ rr:column "city" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:countrycode ] ; rr:objectMap [ rr:column "countrycode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:deadpooled_date ] ; rr:objectMap [ rr:column "deadpooled_date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:description ] ; rr:objectMap [ rr:column "description" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:email_address ] ; rr:objectMap [ rr:column "email_address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:founded_date ] ; rr:objectMap [ rr:column "founded_date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:founded_month ] ; rr:objectMap [ rr:column "founded_month" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:founded_year ] ; rr:objectMap [ rr:column "founded_year" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:freebaseid ] ; rr:objectMap [ rr:column "freebaseid" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:hasstatus ] ; rr:objectMap [ rr:column "hasstatus" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:homepage_url ] ; rr:objectMap [ rr:column "homepage_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:id ] ; rr:objectMap [ rr:column "id" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:label ] ; rr:objectMap [ rr:column "label" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:location_lat ] ; rr:objectMap [ rr:column "location_lat" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:location_lon ] ; rr:objectMap [ rr:column "location_lon" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:number_of_employees ] ; rr:objectMap [ rr:column "number_of_employees" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:one_competitor ] ; rr:objectMap [ rr:column "one_competitor" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:overview ] ; rr:objectMap [ rr:column "overview" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:phone_number ] ; rr:objectMap [ rr:column "phone_number" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:revenue ] ; rr:objectMap [ rr:column "revenue" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:revenuecurrency ] ; rr:objectMap [ rr:column "revenuecurrency" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:revenuedate ] ; rr:objectMap [ rr:column "revenuedate" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:statecode ] ; rr:objectMap [ rr:column "statecode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:url ] ; rr:objectMap [ rr:column "url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:webpage ] ; rr:objectMap [ rr:column "webpage" ]; ] .

<#TriplesMapinvestments> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "csv" ; rr:tableOwner "demo" ; rr:tableName "investments" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://demo.openlinksw.com:8890/csv/investments/id/{id}#this"; rr:class csv:investments; rr:graph <http://demo.openlinksw.com:8890/csv#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:companies ] ; rr:objectMap [ rr:column "companies" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:funded_date ] ; rr:objectMap [ rr:column "funded_date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:funded_month ] ; rr:objectMap [ rr:column "funded_month" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:funded_year ] ; rr:objectMap [ rr:column "funded_year" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:hassourcedescription ] ; rr:objectMap [ rr:column "hassourcedescription" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:hassourceurl ] ; rr:objectMap [ rr:column "hassourceurl" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:id ] ; rr:objectMap [ rr:column "id" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:investors ] ; rr:objectMap [ rr:column "investors" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:label ] ; rr:objectMap [ rr:column "label" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:raised_amount ] ; rr:objectMap [ rr:column "raised_amount" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:raised_currency_code ] ; rr:objectMap [ rr:column "raised_currency_code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:round_code ] ; rr:objectMap [ rr:column "round_code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:shortinvid ] ; rr:objectMap [ rr:column "shortInvID" ]; ] .

<#TriplesMapinvestors> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "csv" ; rr:tableOwner "demo" ; rr:tableName "investors" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://demo.openlinksw.com:8890/csv/investors/id/{id}#this"; rr:class csv:investors; rr:graph <http://demo.openlinksw.com:8890/csv#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:overview_id ] ; rr:objectMap [ rr:column "overview_ID" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:affiliation_name ] ; rr:objectMap [ rr:column "affiliation_name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:alias_list ] ; rr:objectMap [ rr:column "alias_list" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:birthplace ] ; rr:objectMap [ rr:column "birthplace" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:blog_feed_url ] ; rr:objectMap [ rr:column "blog_feed_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:blog_url ] ; rr:objectMap [ rr:column "blog_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:category_code ] ; rr:objectMap [ rr:column "category_code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:city ] ; rr:objectMap [ rr:column "city" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:countrycode ] ; rr:objectMap [ rr:column "countrycode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:created_at ] ; rr:objectMap [ rr:column "created_at" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:deadpooled_date ] ; rr:objectMap [ rr:column "deadpooled_date" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:description ] ; rr:objectMap [ rr:column "description" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:email_address ] ; rr:objectMap [ rr:column "email_address" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:first_name ] ; rr:objectMap [ rr:column "first_name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:founded_month ] ; rr:objectMap [ rr:column "founded_month" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:founded_year ] ; rr:objectMap [ rr:column "founded_year" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:homepage_url ] ; rr:objectMap [ rr:column "homepage_url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:id ] ; rr:objectMap [ rr:column "id" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:investor_category_code ] ; rr:objectMap [ rr:column "investor_category_code" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:investortype ] ; rr:objectMap [ rr:column "investortype" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:label ] ; rr:objectMap [ rr:column "label" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:last_name ] ; rr:objectMap [ rr:column "last_name" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:number_of_employees ] ; rr:objectMap [ rr:column "number_of_employees" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:overview ] ; rr:objectMap [ rr:column "overview" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:phone_number ] ; rr:objectMap [ rr:column "phone_number" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:statecode ] ; rr:objectMap [ rr:column "statecode" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:twitter_username ] ; rr:objectMap [ rr:column "twitter_username" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:updated_at ] ; rr:objectMap [ rr:column "updated_at" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:url ] ; rr:objectMap [ rr:column "url" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant csv:web_presence ] ; rr:objectMap [ rr:column "web_presence" ]; ] .

These mappings are passed through Virtuoso’s R2RML-processor which transforms the input to Virtuoso’s native RDF Views Mapping Language Declarations (or Quad Mappings).

Native Virtuoso RDF Mapping Language-based Mapping Descriptions

SPARQL

PREFIX csv: <http://demo.openlinksw.com:8890/schemas/csv/> 
PREFIX csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX void: <http://rdfs.org/ns/void#> 
PREFIX scovo: <http://purl.org/NET/scovo#> 
PREFIX aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage 
 FROM "csv"."demo"."articles" as articles_s
 { 
   CREATE csv:qm-articles AS GRAPH iri ("http://^{URIQADefaultHost}^/csv#")  
    { 
      # Maps FROM columns of "csv.demo.articles"
      csv:articles (articles_s."id")  a csv:articles ;
      csv:author articles_s."author" as csv:demo-articles-author ;
      csv:companies articles_s."companies" as csv:demo-articles-companies ;
      csv:foundcbref articles_s."foundcbref" as csv:demo-articles-foundcbref ;
      csv:foundnlpref articles_s."foundnlpref" as csv:demo-articles-foundnlpref ;
      csv:id articles_s."id" as csv:demo-articles-id ;
      csv:image articles_s."image" as csv:demo-articles-image ;
      csv:pdate articles_s."pdate" as csv:demo-articles-pdate ;
      csv:pmonth articles_s."pmonth" as csv:demo-articles-pmonth ;
      csv:pyear articles_s."pyear" as csv:demo-articles-pyear ;
      csv:snippet articles_s."snippet" as csv:demo-articles-snippet ;
      csv:source articles_s."source" as csv:demo-articles-source ;
      csv:title articles_s."title" as csv:demo-articles-title ;
      csv:url articles_s."url" as csv:demo-articles-url ;
      csv:snippet_id articles_s."snippet_ID" as csv:demo-articles-snippet_id .

    }
 } ;
SPARQL

PREFIX csv: <http://demo.openlinksw.com:8890/schemas/csv/> 
PREFIX csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX void: <http://rdfs.org/ns/void#> 
PREFIX scovo: <http://purl.org/NET/scovo#> 
PREFIX aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage 
 FROM "csv"."demo"."companies" as companies_s
 { 
   CREATE csv:qm-companies AS GRAPH iri ("http://^{URIQADefaultHost}^/csv#")  
    { 
      # Maps FROM columns of "csv.demo.companies"
      csv:companies (companies_s."id")  a csv:companies ;
      csv:______blog_feed_url companies_s."______blog_feed_url" as csv:demo-companies-______blog_feed_url ;
      csv:blog_url companies_s."blog_url" as csv:demo-companies-blog_url ;
      csv:category_code companies_s."category_code" as csv:demo-companies-category_code ;
      csv:city companies_s."city" as csv:demo-companies-city ;
      csv:countrycode companies_s."countrycode" as csv:demo-companies-countrycode ;
      csv:deadpooled_date companies_s."deadpooled_date" as csv:demo-companies-deadpooled_date ;
      csv:description companies_s."description" as csv:demo-companies-description ;
      csv:email_address companies_s."email_address" as csv:demo-companies-email_address ;
      csv:founded_date companies_s."founded_date" as csv:demo-companies-founded_date ;
      csv:founded_month companies_s."founded_month" as csv:demo-companies-founded_month ;
      csv:founded_year companies_s."founded_year" as csv:demo-companies-founded_year ;
      csv:freebaseid companies_s."freebaseid" as csv:demo-companies-freebaseid ;
      csv:hasstatus companies_s."hasstatus" as csv:demo-companies-hasstatus ;
      csv:homepage_url companies_s."homepage_url" as csv:demo-companies-homepage_url ;
      csv:id companies_s."id" as csv:demo-companies-id ;
      csv:label companies_s."label" as csv:demo-companies-label ;
      csv:location_lat companies_s."location_lat" as csv:demo-companies-location_lat ;
      csv:location_lon companies_s."location_lon" as csv:demo-companies-location_lon ;
      csv:number_of_employees companies_s."number_of_employees" as csv:demo-companies-number_of_employees ;
      csv:one_competitor companies_s."one_competitor" as csv:demo-companies-one_competitor ;
      csv:overview companies_s."overview" as csv:demo-companies-overview ;
      csv:phone_number companies_s."phone_number" as csv:demo-companies-phone_number ;
      csv:revenue companies_s."revenue" as csv:demo-companies-revenue ;
      csv:revenuecurrency companies_s."revenuecurrency" as csv:demo-companies-revenuecurrency ;
      csv:revenuedate companies_s."revenuedate" as csv:demo-companies-revenuedate ;
      csv:statecode companies_s."statecode" as csv:demo-companies-statecode ;
      csv:url companies_s."url" as csv:demo-companies-url ;
      csv:webpage companies_s."webpage" as csv:demo-companies-webpage .

    }
 } ;
SPARQL

PREFIX csv: <http://demo.openlinksw.com:8890/schemas/csv/> 
PREFIX csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX void: <http://rdfs.org/ns/void#> 
PREFIX scovo: <http://purl.org/NET/scovo#> 
PREFIX aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage 
 FROM "csv"."demo"."investments" as investments_s
 { 
   CREATE csv:qm-investments AS GRAPH iri ("http://^{URIQADefaultHost}^/csv#")  
    { 
      # Maps FROM columns of "csv.demo.investments"
      csv:investments (investments_s."id")  a csv:investments ;
      csv:companies investments_s."companies" as csv:demo-investments-companies ;
      csv:funded_date investments_s."funded_date" as csv:demo-investments-funded_date ;
      csv:funded_month investments_s."funded_month" as csv:demo-investments-funded_month ;
      csv:funded_year investments_s."funded_year" as csv:demo-investments-funded_year ;
      csv:hassourcedescription investments_s."hassourcedescription" as csv:demo-investments-hassourcedescription ;
      csv:hassourceurl investments_s."hassourceurl" as csv:demo-investments-hassourceurl ;
      csv:id investments_s."id" as csv:demo-investments-id ;
      csv:investors investments_s."investors" as csv:demo-investments-investors ;
      csv:label investments_s."label" as csv:demo-investments-label ;
      csv:raised_amount investments_s."raised_amount" as csv:demo-investments-raised_amount ;
      csv:raised_currency_code investments_s."raised_currency_code" as csv:demo-investments-raised_currency_code ;
      csv:round_code investments_s."round_code" as csv:demo-investments-round_code ;
      csv:shortinvid investments_s."shortInvID" as csv:demo-investments-shortinvid .

    }
 } ;
SPARQL

PREFIX csv: <http://demo.openlinksw.com:8890/schemas/csv/> 
PREFIX csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX void: <http://rdfs.org/ns/void#> 
PREFIX scovo: <http://purl.org/NET/scovo#> 
PREFIX aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage 
 FROM "csv"."demo"."investors" as investors_s
 { 
   CREATE csv:qm-investors AS GRAPH iri ("http://^{URIQADefaultHost}^/csv#")  
    { 
      # Maps FROM columns of "csv.demo.investors"
      csv:investors (investors_s."id")  a csv:investors ;
      csv:overview_id investors_s."overview_ID" as csv:demo-investors-overview_id ;
      csv:affiliation_name investors_s."affiliation_name" as csv:demo-investors-affiliation_name ;
      csv:alias_list investors_s."alias_list" as csv:demo-investors-alias_list ;
      csv:birthplace investors_s."birthplace" as csv:demo-investors-birthplace ;
      csv:blog_feed_url investors_s."blog_feed_url" as csv:demo-investors-blog_feed_url ;
      csv:blog_url investors_s."blog_url" as csv:demo-investors-blog_url ;
      csv:category_code investors_s."category_code" as csv:demo-investors-category_code ;
      csv:city investors_s."city" as csv:demo-investors-city ;
      csv:countrycode investors_s."countrycode" as csv:demo-investors-countrycode ;
      csv:created_at investors_s."created_at" as csv:demo-investors-created_at ;
      csv:deadpooled_date investors_s."deadpooled_date" as csv:demo-investors-deadpooled_date ;
      csv:description investors_s."description" as csv:demo-investors-description ;
      csv:email_address investors_s."email_address" as csv:demo-investors-email_address ;
      csv:first_name investors_s."first_name" as csv:demo-investors-first_name ;
      csv:founded_month investors_s."founded_month" as csv:demo-investors-founded_month ;
      csv:founded_year investors_s."founded_year" as csv:demo-investors-founded_year ;
      csv:homepage_url investors_s."homepage_url" as csv:demo-investors-homepage_url ;
      csv:id investors_s."id" as csv:demo-investors-id ;
      csv:investor_category_code investors_s."investor_category_code" as csv:demo-investors-investor_category_code ;
      csv:investortype investors_s."investortype" as csv:demo-investors-investortype ;
      csv:label investors_s."label" as csv:demo-investors-label ;
      csv:last_name investors_s."last_name" as csv:demo-investors-last_name ;
      csv:number_of_employees investors_s."number_of_employees" as csv:demo-investors-number_of_employees ;
      csv:overview investors_s."overview" as csv:demo-investors-overview ;
      csv:phone_number investors_s."phone_number" as csv:demo-investors-phone_number ;
      csv:statecode investors_s."statecode" as csv:demo-investors-statecode ;
      csv:twitter_username investors_s."twitter_username" as csv:demo-investors-twitter_username ;
      csv:updated_at investors_s."updated_at" as csv:demo-investors-updated_at ;
      csv:url investors_s."url" as csv:demo-investors-url ;
      csv:web_presence investors_s."web_presence" as csv:demo-investors-web_presence .

    }
 } ;
SPARQL

PREFIX csv: <http://demo.openlinksw.com:8890/schemas/csv/> 
PREFIX csv-stat: <http://demo.openlinksw.com:8890/csv/stat#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX void: <http://rdfs.org/ns/void#> 
PREFIX scovo: <http://purl.org/NET/scovo#> 
PREFIX aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage 
 FROM "csv"."demo"."articlesCount" as articlescount_s
 FROM "csv"."demo"."companiesCount" as companiescount_s
 FROM "csv"."demo"."investmentsCount" as investmentscount_s
 FROM "csv"."demo"."investorsCount" as investorscount_s
 FROM "csv"."demo"."csv__Total" as csv__total_s
 { 
   CREATE csv:qm-VoidStatistics AS GRAPH iri ("http://^{URIQADefaultHost}^/csv#") option (exclusive) 
    { 
      # voID Statistics 
      csv-stat: a void:Dataset as csv:dataset-csv ; 
       void:sparqlEndpoint <http://demo.openlinksw.com:8890/sparql> as csv:dataset-sparql-csv ; 
      void:statItem csv-stat:Stat . 
      csv-stat:Stat a scovo:Item ; 
       rdf:value csv__total_s.cnt as csv:stat-decl-csv ; 
       scovo:dimension void:numOfTriples . 

      csv-stat: void:statItem csv-stat:articlesStat as csv:statitem-csv-articles . 
      csv-stat:articlesStat a scovo:Item as csv:statitem-decl-csv-articles ; 
      rdf:value articlescount_s.cnt as csv:statitem-cnt-csv-articles ; 
      scovo:dimension void:numberOfResources as csv:statitem-type-1-csv-articles ; 
      scovo:dimension csv:articles as csv:statitem-type-2-csv-articles .

      csv-stat: void:statItem csv-stat:companiesStat as csv:statitem-csv-companies . 
      csv-stat:companiesStat a scovo:Item as csv:statitem-decl-csv-companies ; 
      rdf:value companiescount_s.cnt as csv:statitem-cnt-csv-companies ; 
      scovo:dimension void:numberOfResources as csv:statitem-type-1-csv-companies ; 
      scovo:dimension csv:companies as csv:statitem-type-2-csv-companies .

      csv-stat: void:statItem csv-stat:investmentsStat as csv:statitem-csv-investments . 
      csv-stat:investmentsStat a scovo:Item as csv:statitem-decl-csv-investments ; 
      rdf:value investmentscount_s.cnt as csv:statitem-cnt-csv-investments ; 
      scovo:dimension void:numberOfResources as csv:statitem-type-1-csv-investments ; 
      scovo:dimension csv:investments as csv:statitem-type-2-csv-investments .

      csv-stat: void:statItem csv-stat:investorsStat as csv:statitem-csv-investors . 
      csv-stat:investorsStat a scovo:Item as csv:statitem-decl-csv-investors ; 
      rdf:value investorscount_s.cnt as csv:statitem-cnt-csv-investors ; 
      scovo:dimension void:numberOfResources as csv:statitem-type-1-csv-investors ; 
      scovo:dimension csv:investors as csv:statitem-type-2-csv-investors .

    }
 } ;

Re-sync Full Text Indexes

Use the built-in VT_INC_INDEX_DB_DBA_RDF_OBJ() procedure to re-sync Full Text Indexes. Also note that you can use the Virtuoso Scheduler to control re-sync intervals.

DB.DBA.VT_INC_INDEX_DB_DBA_RDF_OBJ ();

Create URL Rewrite Rules to leverage Hyperlinks as Entity Identifiers

These rules enable the use of hyperlinks (specifically, HTTP URIs) as Entity Names equipped with the ability to resolve to a variety of Entity Description Document Types (RDF-Turtle, RDF-XML, JSON-LD, XHTML+RDFa, HTML5+Microdata, HTML5+JSONLD, HTML5+Turtle, etc.).

As the mappings demonstrate, an HTTP GET (either explicit via cURL or implicit via your Browser’s Document Address input field) leads to a redirect on the Virtuoso server to a SPARQL DESCRIBE query that returns a solution (entity description) using a document type preference negotiated between the client (browser or curl) and the built-in Virtuoso Linked Data server.

DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule2',
1,
'(/[^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%23this%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/csv%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule4',
1,
'/csv/stat([^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^/csv/stat%%23%%3E+%%3Fo+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/csv%%23%%3E+WHERE+{+%%3Chttp%%3A//^{URIQADefaultHost}^/csv/stat%%23%%3E+%%3Fp+%%3Fo+}&format=%U',
vector('*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule6',
1,
'/csv/objects/([^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^/csv/objects/%U%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/csv%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule1',
1,
'([^#]*)',
vector('path'),
1,
'/describe/?url=http%%3A//^{URIQADefaultHost}^%U%%23this&graph=http%%3A//^{URIQADefaultHost}^/csv%%23&distinct=0',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule7',
1,
'/csv/stat([^#]*)',
vector('path'),
1,
'/describe/?url=http%%3A//^{URIQADefaultHost}^/csv/stat%%23&graph=http%%3A//^{URIQADefaultHost}^/csv%%23',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_rule5',
1,
'/csv/objects/(.*)',
vector('path'),
1,
'/services/rdf/object.binary?path=%%2Fcsv%%2Fobjects%%2F%U&accept=%U',
vector('path', '*accept*'),
null,
null,
2,
null
);
DB.DBA.URLREWRITE_CREATE _RULELIST ( 'csv_rule_list1', 1, vector ( 'csv_rule1', 'csv_rule7', 'csv_rule5', 'csv_rule2', 'csv_rule4', 'csv_rule6'));
DB.DBA.VHOST_REMOVE (lpath=>'/csv');
DB.DBA.VHOST_DEFINE (lpath=>'/csv', ppath=>'/', vsp_user=>'dba', is_dav=>0,
is_brws=>0, opts=>vector ('url_rewrite', 'csv_rule_list1')
);

-- Virtual directories for ontology
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_owl_rule2',
1,
'(/[^#]*)',
vector('path'),
1,
'/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^%U%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/schemas/csv%%23%%3E&format=%U',
vector('path', '*accept*'),
null,
'(text/rdf.n3)|(application/rdf.xml)|(text/n3)|(application/json)',
2,
null
);
DB.DBA.URLREWRITE_CREATE _REGEX_RULE (
'csv_owl_rule1',
1,
'([^#]*)',
vector('path'),
1,
'/describe/?url=http://^{URIQADefaultHost}^%U',
vector('path'),
null,
null,
2,
303
);
DB.DBA.URLREWRITE_CREATE _RULELIST ( 'csv_owl_rule_list1', 1, vector ( 'csv_owl_rule1', 'csv_owl_rule2'));
DB.DBA.VHOST_REMOVE (lpath=>'/schemas/csv');
DB.DBA.VHOST_DEFINE (lpath=>'/schemas/csv', ppath=>'/', vsp_user=>'dba', is_dav=>0,
is_brws=>0, opts=>vector ('url_rewrite', 'csv_owl_rule_list1')
);

Query Examples

Explore Entity Types in the Physical Named Graph generated via the Mappings above

SELECT (SAMPLE(?s) AS ?sample) 
       (COUNT(1) AS ?count)  
       (?o AS ?entityType)
FROM <urn:demo.openlinksw.com:8890:csv>
WHERE {
        ?s a ?o. 
		FILTER (isIRI(?s)) 
      } 
GROUP BY ?o
ORDER BY DESC (?count)
Query Results Screenshot

Entity Types associated with Articles that mention both Apple and Samsung

SELECT DISTINCT (sample(?s) AS ?sample)
                (COUNT(1) AS ?count)
                ?type
FROM <urn:demo.openlinksw.com:8890:csv>
WHERE {
        ?s a ?type; 
		   ?p ?o .
        ?o bif:contains '"Apple" AND "Samsung"' . 
      } 
GROUP BY ?type 
ORDER BY DESC 2
LIMIT 50 
Screenshot

Additional Demonstration Links

Related

0 Likes