SP²Bench Benchmark Query Translations
We provide the SP²Bench benchmark queries and their translations into a simple triple table scenario (i.e. for a relational database with a single Triples table that contains all RDF triples), the vertically partitioned scenario proposed in [1], and a purely relational scheme (which is described in our ISWC submission An Experimental Comparison of RDF Data Management Approaches in a SPARQL Benchmark Scenario; please contact us if you are interested in a draft of this paper).Some of the queries for the vertically partitioned store require UNIONs over all predicate tables (i.e., Q7, Q9, and Q10). In these queries, the templates #START_UNION# and #END_UNION# identify the subexpressions the union has to be computed over. When running these queries, the templates must be replaced accordingly by a UNION over all predicates in the data set (which, in general, depends on the size of the data). Feel free to contact us if you are planning to run these queries and need any help and/or data conversion scripts.
Jump to query... [ Q1 | Q2 | Q3 | Q4 | Q5 | Q6 | Q7 | Q8 | Q9 | Q10 | Q11 ]
Q1
Return the year of publication of Journal 1 (1940). |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?yr WHERE { ?journal rdf:type bench:Journal . ?journal dc:title "Journal 1 (1940)"^^xsd:string . ?journal dcterms:issued ?yr } Triple-store version: SELECT D3.val AS yr FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.object=D2.ID JOIN Triples T3 ON T1.subject=T3.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D3 ON T3.object=D3.ID WHERE DP1.val='rdf:type' AND DP2.val='dc:title' AND DP3.val='dcterms:issued' AND D1.val='bench:Journal' AND D2.val='"Journal 1 (1940)"^^xsd:string'; Vertically partitioned store version: SELECT Dict3.val AS yr FROM rdf_type RT JOIN Dictionary Dict1 ON RT.object=Dict1.ID JOIN dc_title DT ON RT.subject=DT.subject JOIN Dictionary Dict2 ON DT.object=Dict2.ID JOIN dcterms_issued DI ON RT.subject=DI.subject JOIN Dictionary Dict3 ON DI.object=Dict3.ID WHERE Dict1.val='bench:Journal' AND Dict2.val='"Journal 1 (1940)"^^xsd:string'; Relational scheme version: SELECT D.issued AS yr FROM Venue V JOIN Document D ON D.ID=V.fk_document JOIN VenueType VT ON VT.ID=V.fk_venue_type WHERE VT.name='Journal' AND D.title='Journal 1 (1940)'; |
Q2
Extract all inproceedings with properties dc:creator, bench:booktitle, dc:title, swrc:pages, dcterms:partOf, rdfs:seeAlso, foaf:homepage dcterms:issued, and optionally bench:abstract, including these properties. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX swrc: <http://swrc.ontoware.org/ontology#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?inproc ?author ?booktitle ?title ?proc ?ee ?page ?url ?yr ?abstract WHERE { ?inproc rdf:type bench:Inproceedings . ?inproc dc:creator ?author . ?inproc bench:booktitle ?booktitle . ?inproc dc:title ?title . ?inproc dcterms:partOf ?proc . ?inproc rdfs:seeAlso ?ee . ?inproc swrc:pages ?page . ?inproc foaf:homepage ?url . ?inproc dcterms:issued ?yr OPTIONAL { ?inproc bench:abstract ?abstract } } ORDER BY ?yr Triple-store version: SELECT D0.val AS inproc, D2.val AS author, D3.val AS booktitle, D4.val AS title, D5.val AS proc, D6.val AS ee, D7.val AS page, D8.val AS URL, D9.val AS yr, AB.val AS abstract FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D0 ON T1.subject=D0.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.object=D2.ID JOIN Triples T3 ON T1.subject=T3.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D3 ON T3.object=D3.ID JOIN Triples T4 ON T1.subject=T4.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Dictionary D4 ON T4.object=D4.ID JOIN Triples T5 ON T1.subject=T5.subject JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Dictionary D5 ON T5.object=D5.ID JOIN Triples T6 ON T1.subject=T6.subject JOIN Dictionary DP6 ON T6.predicate=DP6.ID JOIN Dictionary D6 ON T6.object=D6.ID JOIN Triples T7 ON T1.subject=T7.subject JOIN Dictionary DP7 ON T7.predicate=DP7.ID JOIN Dictionary D7 ON T7.object=D7.ID JOIN Triples T8 ON T1.subject=T8.subject JOIN Dictionary DP8 ON T8.predicate=DP8.ID JOIN Dictionary D8 ON T8.object=D8.ID JOIN Triples T9 ON T1.subject=T9.subject JOIN Dictionary DP9 ON T9.predicate=DP9.ID JOIN Dictionary D9 ON T9.object=D9.ID LEFT JOIN ( SELECT * FROM Triples T10 JOIN Dictionary DP10 ON T10.predicate=DP10.ID JOIN Dictionary D10 ON T10.object=D10.ID WHERE DP10.val='bench:abstract' ) AB ON T1.subject=AB.subject WHERE DP1.val='rdf:type' AND DP2.val='dc:creator' AND DP3.val='bench:booktitle' AND DP4.val='dc:title' AND DP5.val='dcterms:partOf' AND DP6.val='rdfs:seeAlso' AND DP7.val='swrc:pages' AND DP8.val='foaf:homepage' AND DP9.val='dcterms:issued' AND D1.val='bench:Inproceedings' ORDER BY D9.val; Vertically partitioned store version: SELECT D1.val AS inproc, D3.val AS author, D4.val AS booktitle, D5.val AS title, D6.val AS proc, D7.val AS ee, D8.val AS page, D9.val AS URL, D10.val AS yr, D11.val AS abstract FROM rdf_type RT JOIN Dictionary D1 ON RT.subject=D1.ID JOIN Dictionary D2 ON RT.object=D2.ID JOIN dc_creator DC ON RT.subject=DC.subject JOIN Dictionary D3 ON DC.object=D3.ID JOIN bench_booktitle BB ON RT.subject=BB.subject JOIN Dictionary D4 ON BB.object=D4.ID JOIN dc_title DT ON RT.subject=DT.subject JOIN Dictionary D5 ON DT.object=D5.ID JOIN dcterms_partOf DP ON RT.subject=DP.subject JOIN Dictionary D6 ON DP.object=D6.ID JOIN rdfs_seeAlso RS ON RT.subject=RS.subject JOIN Dictionary D7 ON RS.object=D7.ID JOIN swrc_pages SP ON RT.subject=SP.subject JOIN Dictionary D8 ON SP.object=D8.ID JOIN foaf_homepage FH ON RT.subject=FH.subject JOIN Dictionary D9 ON FH.object=D9.ID JOIN dcterms_issued DI ON RT.subject=DI.subject JOIN Dictionary D10 ON DI.object=D10.ID LEFT JOIN ( bench_abstract BA JOIN Dictionary D11 ON BA.object=D11.ID ) ON RT.subject=BA.subject ORDER BY D10.val; Relational scheme version: SELECT D1.stringid AS inproc, Pe.name AS author, D1.booktitle AS booktitle, D1.title AS title, D2.stringid AS proc, DSA.seeAlso AS ee, P.pages AS page, DH.homepage AS url, D1.issued AS yr, AB.txt AS abstract FROM Document D1 JOIN Publication P ON P.fk_document=D1.ID JOIN PublicationType PT ON P.fk_publication_type=PT.ID JOIN Author A ON P.ID=A.fk_publication JOIN Person Pe ON Pe.ID=A.fk_person JOIN Document_seeAlso DSA ON DSA.fk_document=D1.ID JOIN Document_homepage DH ON DH.fk_document=D1.ID JOIN Venue V ON P.fk_venue=V.ID JOIN Document D2 ON D2.ID=V.fk_document LEFT OUTER JOIN Abstract AB ON AB.fk_publication=P.ID WHERE PT.name='Inproceedings' AND D1.booktitle IS NOT NULL AND D1.title IS NOT NULL AND P.pages IS NOT NULL AND D1.issued IS NOT NULL ORDER BY yr; |
Q3
(a) Select all articles with property swrc:pages. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX swrc: <http://swrc.ontoware.org/ontology#> SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:pages) } Triple-store version: SELECT D1.val AS article FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.subject=D1.ID JOIN Dictionary D2 ON T1.object=D2.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID WHERE DP1.val='rdf:type' AND DP2.val='swrc:pages' AND D2.val='bench:Article'; Vertically partitioned store version: SELECT D1.val AS article FROM rdf_type RT JOIN Dictionary D1 ON RT.subject=D1.ID JOIN Dictionary D2 ON RT.object=D2.ID JOIN swrc_pages SP ON RT.subject=SP.subject WHERE D2.val='bench:Article'; Relational scheme version: SELECT D.stringid AS article FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN PublicationType PT ON P.fk_publication_type=PT.ID WHERE PT.name='Article' AND P.pages IS NOT NULL; |
(b) Select all articles with property swrc:month. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX swrc: <http://swrc.ontoware.org/ontology#> SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:month) } Triple-store version: SELECT D1.val AS article FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.subject=D1.ID JOIN Dictionary D2 ON T1.object=D2.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID WHERE DP1.val='rdf:type' AND DP2.val='swrc:month' AND D2.val='bench:Article'; Vertically partitioned store version: SELECT D1.val AS article FROM rdf_type RT JOIN Dictionary D1 ON RT.subject=D1.ID JOIN Dictionary D2 ON RT.object=D2.ID JOIN swrc_month SM ON RT.subject=SM.subject WHERE D2.val='bench:Article'; Relational scheme version: SELECT D.stringid AS article FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN PublicationType PT ON P.fk_publication_type=PT.ID WHERE PT.name='Article' AND D.mnth IS NOT NULL; |
(c) Select all articles with property swrc:isbn. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX swrc: <http://swrc.ontoware.org/ontology#> PREFIX bench: <http://localhost/vocabulary/bench/> SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:isbn) } Triple-store version: SELECT D1.val AS article FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.subject=D1.ID JOIN Dictionary D2 ON T1.object=D2.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID WHERE DP1.val='rdf:type' AND DP2.val='swrc:isbn' AND D2.val='bench:Article'; Vertically partitioned store version: SELECT D1.val AS article FROM rdf_type RT JOIN Dictionary D1 ON RT.subject=D1.ID JOIN Dictionary D2 ON RT.object=D2.ID JOIN swrc_isbn SI ON RT.subject=SI.subject WHERE D2.val='bench:Article'; Relational scheme version: SELECT D.stringid AS article FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN PublicationType PT ON P.fk_publication_type=PT.ID WHERE PT.name='Article' AND D.isbn IS NOT NULL; |
Q4
Select all distinct pairs of article author names for authors that have published in the same journal. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX swrc: <http://swrc.ontoware.org/ontology#> SELECT DISTINCT ?name1 ?name2 WHERE { ?article1 rdf:type bench:Article . ?article2 rdf:type bench:Article . ?article1 dc:creator ?author1 . ?author1 foaf:name ?name1 . ?article2 dc:creator ?author2 . ?author2 foaf:name ?name2 . ?article1 swrc:journal ?journal . ?article2 swrc:journal ?journal FILTER (?name1<?name2) } Triple-store version: SELECT DISTINCT D2.val AS name1, D4.val AS name2 FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Triples T3 ON T2.object=T3.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D2 ON T3.object=D2.ID JOIN Triples T4 ON T1.subject=T4.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Triples T5 ON T4.object=T5.object JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Triples T6 ON T5.subject=T6.subject JOIN Dictionary DP6 ON T6.predicate=DP6.ID JOIN Dictionary D3 ON T6.object=D3.ID JOIN Triples T7 ON T6.subject=T7.subject JOIN Dictionary DP7 ON T7.predicate=DP7.ID JOIN Triples T8 ON T7.object=T8.subject JOIN Dictionary DP8 ON T8.predicate=DP8.ID JOIN Dictionary D4 ON T8.object=D4.ID WHERE DP1.val='rdf:type' AND DP2.val='dc:creator' AND DP3.val='foaf:name' AND DP4.val='swrc:journal' AND DP5.val='swrc:journal' AND DP6.val='rdf:type' AND DP7.val='dc:creator' AND DP8.val='foaf:name' AND D1.val='bench:Article' AND D3.val='bench:Article' AND D2.val<D4.val; Vertically partitioned store version: SELECT DISTINCT D2.val AS name1, D4.val AS name2 FROM rdf_type RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN dc_creator DC1 ON RT1.subject=DC1.subject JOIN foaf_name FN1 ON DC1.object=FN1.subject JOIN Dictionary D2 ON FN1.object=D2.ID JOIN swrc_journal SJ1 ON RT1.subject=SJ1.subject JOIN swrc_journal SJ2 ON SJ1.object=SJ2.object JOIN rdf_type RT2 ON SJ2.subject=RT2.subject JOIN Dictionary D3 ON RT2.object=D3.ID JOIN dc_creator DC2 ON RT2.subject=DC2.subject JOIN foaf_name FN2 ON DC2.object=FN2.subject JOIN Dictionary D4 ON FN2.object=D4.ID WHERE D1.val='bench:Article' AND D3.val='bench:Article' AND D2.val<D4.val ; Relational scheme version: SELECT DISTINCT Pe1.name AS name1, Pe2.name AS name2 FROM Publication P1 JOIN PublicationType PT1 ON P1.fk_publication_type=PT1.ID JOIN Author A1 ON A1.fk_publication=P1.ID JOIN Person Pe1 ON A1.fk_person=Pe1.ID JOIN Venue V ON P1.fk_venue=V.ID JOIN Publication P2 ON P2.fk_venue=V.ID JOIN PublicationType PT2 ON P2.fk_publication_type=PT2.ID JOIN Author A2 ON A2.fk_publication=P2.ID JOIN Person Pe2 ON A2.fk_person=Pe2.ID WHERE PT1.name='Article' AND PT2.name='Article' AND Pe1.name<Pe2.name; |
Q5
(a) Return the names of all persons that occur as author of at least one inproceeding and at least one article. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?person ?name WHERE { ?article rdf:type bench:Article . ?article dc:creator ?person . ?inproc rdf:type bench:Inproceedings . ?inproc dc:creator ?person2 . ?person foaf:name ?name . ?person2 foaf:name ?name2 FILTER (?name=?name2) } Triple-store version: SELECT DISTINCT D2.val AS person, D3.val AS name FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.object=D2.ID JOIN Triples T3 ON T2.object=T3.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D3 ON T3.object=D3.ID, Triples T4 JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Dictionary D4 ON T4.object=D4.ID JOIN Triples T5 ON T4.subject=T5.subject JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Dictionary D5 ON T5.object=D5.ID JOIN Triples T6 ON T5.object=T6.subject JOIN Dictionary DP6 ON T6.predicate=DP6.ID WHERE DP1.val='rdf:type' AND DP2.val='dc:creator' AND DP3.val='foaf:name' AND DP4.val='rdf:type' AND DP5.val='dc:creator' AND DP6.val='foaf:name' AND D1.val='bench:Article' AND D4.val='bench:Inproceedings' AND T3.object=T6.object; Vertically partitioned store version: SELECT DISTINCT D2.val AS person, D3.val AS name FROM rdf_type RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN dc_creator DC1 ON RT1.subject=DC1.subject JOIN Dictionary D2 ON DC1.object=D2.ID JOIN foaf_name FN1 ON DC1.object=FN1.subject JOIN Dictionary D3 ON FN1.object=D3.ID, rdf_type RT2 JOIN Dictionary D4 ON RT2.object=D4.ID JOIN dc_creator DC2 ON RT2.subject=DC2.subject JOIN foaf_name FN2 ON DC2.object=FN2.subject WHERE D1.val='bench:Article' AND D4.val='bench:Inproceedings' AND FN1.object=FN2.object; Relational scheme version: SELECT DISTINCT Pe1.stringid AS person, Pe1.name AS name FROM Publication P1 JOIN PublicationType PT1 ON P1.fk_publication_type=PT1.ID JOIN Author A1 ON P1.ID=A1.fk_publication JOIN Person Pe1 ON A1.fk_person=Pe1.ID, Publication P2 JOIN PublicationType PT2 ON P2.fk_publication_type=PT2.ID JOIN Author A2 ON P2.ID=A2.fk_publication JOIN Person Pe2 ON A2.fk_person=Pe2.ID WHERE PT1.name='Article' AND PT2.name='Inproceedings' AND Pe1.name=Pe2.name ; |
(b) Return the names of all persons that occur as author of at least one inproceeding and at least one article (same as Q5a). |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX bench: <http://localhost/vocabulary/bench/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?person ?name WHERE { ?article rdf:type bench:Article . ?article dc:creator ?person . ?inproc rdf:type bench:Inproceedings . ?inproc dc:creator ?person . ?person foaf:name ?name } Triple-store version: SELECT DISTINCT D2.val AS person, D4.val AS name FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.object=D2.ID JOIN Triples T3 ON T2.object=T3.object JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Triples T4 ON T3.subject=T4.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Dictionary D3 ON T4.object=D3.ID JOIN Triples T5 ON T3.object=T5.subject JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Dictionary D4 ON T5.object=D4.ID WHERE DP1.val='rdf:type' AND DP2.val='dc:creator' AND DP3.val='dc:creator' AND DP4.val='rdf:type' AND DP5.val='foaf:name' AND D1.val='bench:Article' AND D3.val='bench:Inproceedings'; Vertically partitioned store version: SELECT DISTINCT D2.val AS person, D4.val AS name FROM rdf_type RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN dc_creator DC1 ON RT1.subject=DC1.subject JOIN Dictionary D2 ON DC1.object=D2.ID JOIN dc_creator DC2 ON DC1.object=DC2.object JOIN rdf_type RT2 ON DC2.subject=RT2.subject JOIN Dictionary D3 ON RT2.object=D3.ID JOIN foaf_name FN ON DC2.object=FN.subject JOIN Dictionary D4 ON FN.object=D4.ID WHERE D1.val='bench:Article' AND D3.val='bench:Inproceedings'; Relational scheme version: SELECT DISTINCT Pe1.stringid AS person, Pe1.name AS name FROM Publication P1 JOIN PublicationType PT1 ON P1.fk_publication_type=PT1.ID JOIN Author A1 ON P1.ID=A1.fk_publication JOIN Person Pe1 ON A1.fk_person=Pe1.ID JOIN Person Pe2 ON Pe1.ID=Pe2.ID JOIN Author A2 ON A2.fk_person=Pe2.ID JOIN Publication P2 ON P2.ID=A2.fk_publication JOIN PublicationType PT2 ON PT2.ID=P2.fk_publication_type WHERE PT1.name='Article' AND PT2.name='Inproceedings' ; |
Q6
Return, for each year, the set of all publications authored by persons that have not published in years before. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?yr ?name ?document WHERE { ?class rdfs:subClassOf foaf:Document . ?document rdf:type ?class . ?document dcterms:issued ?yr . ?document dc:creator ?author . ?author foaf:name ?name OPTIONAL { ?class2 rdfs:subClassOf foaf:Document . ?document2 rdf:type ?class2 . ?document2 dcterms:issued ?yr2 . ?document2 dc:creator ?author2 FILTER (?author=?author2 && ?yr2<?yr) } FILTER (!bound(?author2)) } Triple-store version: SELECT L1.yr AS yr, L1.name AS name, L1.document AS document FROM ( SELECT T1.subject AS class, D2.val AS document, D3.val AS yr, D4.val AS author, D5.val AS name FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.object JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.subject=D2.ID JOIN Triples T3 ON T3.subject=T2.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D3 ON T3.object=D3.ID JOIN Triples T4 ON T4.subject=T3.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Dictionary D4 ON T4.object=D4.ID JOIN Triples T5 ON T5.subject=T4.object JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Dictionary D5 ON T5.object=D5.ID WHERE DP1.val='rdfs:subClassOf' AND DP2.val='rdf:type' AND DP3.val='dcterms:issued' AND DP4.val='dc:creator' AND DP5.val='foaf:name' AND D1.val='foaf:Document' ) L1 LEFT JOIN ( SELECT T1.subject AS class, D2.val AS document, D3.val AS yr, D4.val AS author FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.object JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.subject=D2.ID JOIN Triples T3 ON T3.subject=T2.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D3 ON T3.object=D3.ID JOIN Triples T4 ON T4.subject=T3.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Dictionary D4 ON T4.object=D4.ID WHERE DP1.val='rdfs:subClassOf' AND DP2.val='rdf:type' AND DP3.val='dcterms:issued' AND DP4.val='dc:creator' AND D1.val='foaf:Document' ) L2 ON L1.author=L2.author AND L2.yr<L1.yr WHERE L2.author IS NULL; Vertically partitioned store version: SELECT L1.yr AS yr, L1.name AS name, L1.document AS document FROM ( SELECT RT1.subject AS class, D2.val AS document, D3.val AS yr, DC.object AS author, D4.val AS name FROM rdfs_subClassOf RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN rdf_type RT2 ON RT1.subject=RT2.object JOIN Dictionary D2 ON RT2.subject=D2.ID JOIN dcterms_issued DI ON DI.subject=RT2.subject JOIN Dictionary D3 ON DI.object=D3.ID JOIN dc_creator DC ON DC.subject=DI.subject JOIN foaf_name FN ON DC.object=FN.subject JOIN Dictionary D4 ON FN.object=D4.ID WHERE D1.val='foaf:Document' ) AS L1 LEFT JOIN ( SELECT RT1.subject AS class, D2.val AS document, D3.val AS yr, DC.object AS author FROM rdfs_subClassOf RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN rdf_type RT2 ON RT1.subject=RT2.object JOIN Dictionary D2 ON RT2.subject=D2.ID JOIN dcterms_issued DI ON DI.subject=RT2.subject JOIN Dictionary D3 ON DI.object=D3.ID JOIN dc_creator DC ON DC.subject=DI.subject WHERE D1.val='foaf:Document' ) AS L2 ON L1.author=L2.author AND L2.yr<L1.yr WHERE L2.author IS NULL; Relational scheme version: SELECT D.issued AS yr, Pe.name AS name, D.stringid AS document FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN Author A ON P.ID=A.fk_publication JOIN Person Pe ON Pe.ID=A.fk_person WHERE NOT EXISTS ( SELECT * FROM Publication P2 JOIN Document D2 ON D2.ID=P2.fk_document JOIN Author A2 ON P2.ID=A2.fk_publication WHERE A.fk_person=A2.fk_person AND D2.issued<D.issued ) AND D.issued IS NOT NULL; |
Q7
Return the titles of all papers that have been cited at least once, but not by any paper that has not been cited itself. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT DISTINCT ?title WHERE { ?class rdfs:subClassOf foaf:Document . ?doc rdf:type ?class . ?doc dc:title ?title . ?bag2 ?member2 ?doc . ?doc2 dcterms:references ?bag2 OPTIONAL { ?class3 rdfs:subClassOf foaf:Document . ?doc3 rdf:type ?class3 . ?doc3 dcterms:references ?bag3 . ?bag3 ?member3 ?doc OPTIONAL { ?class4 rdfs:subClassOf foaf:Document . ?doc4 rdf:type ?class4 . ?doc4 dcterms:references ?bag4 . ?bag4 ?member4 ?doc3 } FILTER (!bound(?doc4)) } FILTER (!bound(?doc3)) } Triple-store version: SELECT DISTINCT title FROM ( SELECT T1.subject AS class, T2.subject AS doc, D2.val AS title, T5.subject AS doc2, T5.object AS bag2 FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T2.object=T1.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Triples T3 ON T3.subject=T2.subject JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Dictionary D2 ON T3.object=D2.ID JOIN Triples T4 ON T4.object=T3.subject JOIN Triples T5 ON T5.object=T4.subject JOIN Dictionary DP5 ON T5.predicate=DP5.ID WHERE DP1.val='rdfs:subClassOf' AND DP2.val='rdf:type' AND DP3.val='dc:title' AND DP5.val='dcterms:references' AND D1.val='foaf:Document' ) S1 LEFT JOIN ( SELECT T6.subject AS class3, T7.subject AS doc3, T8.object AS bag3, T9.object AS join1 FROM Triples T6 JOIN Dictionary DP6 ON T6.predicate=DP6.ID JOIN Dictionary D3 ON T6.object=D3.ID JOIN Triples T7 ON T7.object=T6.subject JOIN Dictionary DP7 ON T7.predicate=DP7.ID JOIN Triples T8 ON T8.subject=T7.subject JOIN Dictionary DP8 ON T8.predicate=DP8.ID JOIN Triples T9 ON T9.subject=T8.object LEFT JOIN ( SELECT T10.subject AS class4, T11.subject AS doc4, T12.object AS bag4, T13.object AS join2 FROM Triples T10 JOIN Dictionary DP10 ON T10.predicate=DP10.ID JOIN Dictionary D4 ON T10.object=D4.ID JOIN Triples T11 ON T11.object=T10.subject JOIN Dictionary DP11 ON T11.predicate=DP11.ID JOIN Triples T12 ON T12.subject=T11.subject JOIN Dictionary DP12 ON T12.predicate=DP12.ID JOIN Triples T13 ON T13.subject=T12.object WHERE DP10.val='rdfs:subClassOf' AND DP11.val='rdf:type' AND DP12.val='dcterms:references' AND D4.val='foaf:Document' ) S3 ON T7.subject=S3.join2 WHERE DP6.val='rdfs:subClassOf' AND DP7.val='rdf:type' AND DP8.val='dcterms:references' AND D3.val='foaf:Document' AND doc4 IS NULL ) S2 ON doc=S2.join1 WHERE doc3 IS NULL; Vertically partitioned store version: SELECT DISTINCT title FROM ( #START_UNION# SELECT RT1.subject AS class, RT2.subject AS doc, D2.val AS title, DR.subject AS doc2, DR.object AS bag2 FROM rdfs_subClassOf RT1 JOIN Dictionary D1 ON RT1.object=D1.ID JOIN rdf_type RT2 ON RT2.object=RT1.subject JOIN dc_title DT ON DT.subject=RT2.subject JOIN Dictionary D2 ON DT.object=D2.ID JOIN (#PREDICATE_SO#) AS T ON T.object=DT.subject JOIN dcterms_references DR ON DR.object=T.subject WHERE D1.val='foaf:Document' #END_UNION# ) AS S1 LEFT JOIN ( SELECT RT3.subject AS class3, RT4.subject AS doc3, DR2.object AS bag3, T2.object AS join1 FROM ( rdfs_subClassOf RT3 JOIN Dictionary D3 ON RT3.object=D3.ID JOIN rdf_type RT4 ON RT4.object=RT3.subject JOIN dcterms_references DR2 ON DR2.subject=RT4.subject JOIN ( #START_UNION# #PREDICATE_SO# #END_UNION# ) AS T2 ON T2.subject=DR2.object LEFT JOIN ( SELECT RT5.subject AS class4, RT6.subject AS doc4, DR3.object AS bag4, T3.object AS join2 FROM rdfs_subClassOf RT5 JOIN Dictionary D4 ON RT5.object=D4.ID JOIN rdf_type RT6 ON RT6.object=RT5.subject JOIN dcterms_references DR3 ON DR3.subject=RT6.subject JOIN ( #START_UNION# #PREDICATE_SO# #END_UNION# ) AS T3 ON T3.subject=DR3.object WHERE D4.val='foaf:Document' ) AS S3 ON RT4.subject=S3.join2 ) WHERE D3.val='foaf:Document' AND doc4 IS NULL ) AS S2 ON doc=S2.join1 WHERE doc3 IS NULL; Relational scheme version: SELECT DISTINCT D.title AS title FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN Reference R ON P.ID=R.fk_to WHERE P.ID NOT IN ( SELECT fk_to FROM Reference R2 WHERE R2.fk_from NOT IN ( SELECT fk_to FROM Reference R3 ) ); |
Q8
Compute authors that have published with Paul Erdoes, or with an author that has published with Paul Erdoes. |
SPARQL version:PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT DISTINCT ?name WHERE { ?erdoes rdf:type foaf:Person . ?erdoes foaf:name "Paul Erdoes"^^xsd:string . { ?document dc:creator ?erdoes . ?document dc:creator ?author . ?document2 dc:creator ?author . ?document2 dc:creator ?author2 . ?author2 foaf:name ?name FILTER (?author!=?erdoes && ?document2!=?document && ?author2!=?erdoes && ?author2!=?author) } UNION { ?document dc:creator ?erdoes. ?document dc:creator ?author. ?author foaf:name ?name FILTER (?author!=?erdoes) } } Triple-store version: SELECT DISTINCT name FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.object=D1.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID JOIN Dictionary D2 ON T2.object=D2.ID JOIN ( SELECT name, erdoes FROM ( SELECT D3.val AS name, T3.object AS erdoes FROM Triples T3 JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Triples T4 ON T3.subject=T4.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Triples T5 ON T4.object=T5.subject JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Dictionary D3 ON T5.object=D3.ID WHERE DP3.val='dc:creator' AND DP4.val='dc:creator' AND DP5.val='foaf:name' AND NOT T3.object=T4.object ) L UNION ( SELECT D3.val AS name, T3.object AS erdoes FROM Triples T3 JOIN Dictionary DP3 ON T3.predicate=DP3.ID JOIN Triples T4 ON T3.subject=T4.subject JOIN Dictionary DP4 ON T4.predicate=DP4.ID JOIN Triples T5 ON T4.object=T5.object JOIN Dictionary DP5 ON T5.predicate=DP5.ID JOIN Triples T6 ON T5.subject=T6.subject JOIN Dictionary DP6 ON T6.predicate=DP6.ID JOIN Triples T7 ON T6.object=T7.subject JOIN Dictionary DP7 ON T7.predicate=DP7.ID JOIN Dictionary D3 ON T7.object=D3.ID WHERE DP3.val='dc:creator' AND DP4.val='dc:creator' AND DP5.val='dc:creator' AND DP6.val='dc:creator' AND DP7.val='foaf:name' AND NOT T4.object=T3.object AND NOT T5.subject=T3.subject AND NOT T6.object=T3.object AND NOT T4.object=T6.object ) ) R ON T2.subject=R.erdoes WHERE DP1.val='rdf:type' AND DP2.val='foaf:name' AND D1.val='foaf:Person' AND D2.val='"Paul Erdoes"^^xsd:string'; Vertically partitioned store version: SELECT DISTINCT name FROM rdf_type RT JOIN Dictionary D1 ON RT.object=D1.ID JOIN foaf_name FN ON RT.subject=FN.subject JOIN Dictionary D2 ON FN.object=D2.ID JOIN ( SELECT name, erdoes FROM ( SELECT D3.val AS name, DC1.object AS erdoes FROM dc_creator DC1 JOIN dc_creator DC2 ON DC1.subject=DC2.subject JOIN foaf_name FN2 ON DC2.object=FN2.subject JOIN Dictionary D3 ON FN2.object=D3.ID WHERE NOT DC1.object=DC2.object ) AS L UNION ( SELECT D3.val AS name, DC1.object AS erdoes FROM dc_creator DC1 JOIN dc_creator DC2 ON DC1.subject=DC2.subject JOIN dc_creator DC3 ON DC2.object=DC3.object JOIN dc_creator DC4 ON DC3.subject=DC4.subject JOIN foaf_name FN2 ON DC4.object=FN2.subject JOIN Dictionary D3 ON FN2.object=D3.ID WHERE NOT DC2.object=DC1.object AND NOT DC3.subject=DC1.subject AND NOT DC4.object=DC1.object AND NOT DC2.object=DC4.object ) ) AS R ON FN.subject=R.erdoes WHERE D1.val='foaf:Person' AND D2.val='"Paul Erdoes"^^xsd:string'; Relational scheme version: SELECT DISTINCT name FROM ( ( SELECT Pe4.name AS name FROM Author A1 JOIN Person Pe1 ON A1.fk_person=Pe1.ID JOIN Author A2 ON A1.fk_publication=A2.fk_publication JOIN Author A3 ON A2.fk_person=A3.fk_person JOIN Author A4 ON A3.fk_publication=A4.fk_publication JOIN Person Pe4 ON A4.fk_person=Pe4.ID WHERE Pe1.name='Paul Erdoes' AND NOT Pe4.name='Paul Erdoes' ) UNION ( SELECT Pe2.name AS name FROM Author A1 JOIN Person Pe1 ON A1.fk_person=Pe1.ID JOIN Author A2 ON A1.fk_publication=A2.fk_publication JOIN Person Pe2 ON A2.fk_person=Pe2.ID WHERE Pe1.name='Paul Erdoes' AND NOT Pe2.name='Paul Erdoes' )) AS dist; |
Q9
Return incoming and outcoming properties of persons. |
SPARQL version:PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?predicate WHERE { { ?person rdf:type foaf:Person . ?subject ?predicate ?person } UNION { ?person rdf:type foaf:Person . ?person ?predicate ?object } } Triple-store version: SELECT DISTINCT L.predicate AS predicate FROM ( SELECT D1.val AS subject, DP2.val AS predicate FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.subject=D1.ID JOIN Dictionary D2 ON T1.object=D2.ID JOIN Triples T2 ON T1.subject=T2.object JOIN Dictionary DP2 ON T2.predicate=DP2.ID WHERE DP1.val='rdf:type' AND D2.val='foaf:Person' UNION SELECT D1.val AS subject, DP2.val AS predicate FROM Triples T1 JOIN Dictionary DP1 ON T1.predicate=DP1.ID JOIN Dictionary D1 ON T1.subject=D1.ID JOIN Dictionary D2 ON T1.object=D2.ID JOIN Triples T2 ON T1.subject=T2.subject JOIN Dictionary DP2 ON T2.predicate=DP2.ID WHERE DP1.val='rdf:type' AND D2.val='foaf:Person' ) L; Vertically partitioned store version: SELECT DISTINCT L.predicate FROM ( #START_UNION# SELECT RT.subject, T.predicate FROM rdf_type RT JOIN Dictionary D ON D.ID=RT.object JOIN (#PREDICATE_PO#) AS T ON RT.subject=T.object WHERE D.val='foaf:Person' #END_UNION# UNION #START_UNION# SELECT RT.subject, T.predicate FROM rdf_type RT JOIN Dictionary D ON D.ID=RT.object JOIN (#PREDICATE_SP#) AS T ON RT.subject=T.subject WHERE D.val='foaf:Person' #END_UNION# ) AS L (subject,predicate); Relational scheme version: n/a |
Q10
Return all subjects that stand in any relation to Paul Erdoes. In our scenario, the query might also be formulated as "Return publications and venues in which Paul Erdoes is involved either as author or as editor". |
SPARQL version:PREFIX person: <http://localhost/persons/> SELECT ?subject ?predicate WHERE { ?subject ?predicate person:Paul_Erdoes } Triple-store version: SELECT D1.val AS subject, DP1.val AS predicate FROM Triples T JOIN Dictionary DP1 ON T.predicate=DP1.ID JOIN Dictionary D1 ON T.subject=D1.ID JOIN Dictionary D2 ON T.object=D2.ID WHERE D2.val='person:Paul_Erdoes'; Vertically partitioned store version: #START_UNION# SELECT D1.val AS subject, T.predicate AS predicate FROM (#PREDICATE_SPO#) T JOIN Dictionary D1 ON D1.ID=T.subject JOIN Dictionary D2 ON D2.ID=T.object WHERE D2.val='person:Paul_Erdoes' #END_UNION# ; Relational scheme version: SELECT D.stringid AS subject, 'dc:creator' AS predicate FROM Author A JOIN Publication P ON A.fk_publication=P.ID JOIN Document D ON D.ID=P.fk_document JOIN Person Pe ON A.fk_person=Pe.ID WHERE Pe.stringid='Paul_Erdoes' UNION SELECT D.stringid AS subject, 'swrc:editor' AS predicate FROM Editor E JOIN Document D ON D.ID=E.fk_document JOIN Venue V ON E.fk_document=D.ID JOIN Person Pe ON E.fk_person=Pe.ID WHERE Pe.stringid='Paul_Erdoes'; |
Q11
Return (up to) 10 electronic edition URLs starting from the 51th publication, in lexicographical order. |
SPARQL version:PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?ee WHERE { ?publication rdfs:seeAlso ?ee } ORDER BY ?ee LIMIT 10 OFFSET 50 Triple-store version: SELECT D.val AS ee FROM Triples T JOIN Dictionary DP ON T.predicate=DP.ID JOIN Dictionary D ON T.object=D.ID WHERE DP.val='rdfs:seeAlso' ORDER BY ee LIMIT 10 OFFSET 50; Vertically partitioned store version: SELECT D.val AS ee FROM rdfs_seeAlso RSA JOIN Dictionary D ON RSA.object=D.ID ORDER BY D.val LIMIT 10 OFFSET 50 ; Relational scheme version: SELECT DSA.seeAlso FROM Publication P JOIN Document D ON D.ID=P.fk_document JOIN Document_seeAlso DSA ON DSA.fk_document=D.ID ORDER BY DSA.seeAlso LIMIT 10 OFFSET 50 ; |
References
[1] D. J. Abadi, A. Marcus, S. R. Madden, and K. HollenbachScalable Semantic Web Data Management Using Vertical Partitioning
In Proceedings VLDB 2007.
Last modified: February 3, 2009