/////////////////////////////////////////////////////////// (Q1) /* * Return the year of publication of 'Journal 1 (1940)'. */ PREFIX rdf: PREFIX dc: PREFIX dcterms: PREFIX bench: PREFIX xsd: SELECT ?yr WHERE { ?journal rdf:type bench:Journal . ?journal dc:title "Journal 1 (1940)"^^xsd:string . ?journal dcterms:issued ?yr } /////////////////////////////////////////////////////////// (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, order by year. */ PREFIX rdf: PREFIX rdfs: PREFIX swrc: PREFIX foaf: PREFIX bench: PREFIX dc: PREFIX dcterms: 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 /////////////////////////////////////////////////////////// (Q3a) /* * Select all articles with property 'swrc:pages'. */ PREFIX rdf: PREFIX bench: PREFIX swrc: SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:pages) } /////////////////////////////////////////////////////////// (Q3b) /* * Select all articles with property 'swrc:month'. */ PREFIX rdf: PREFIX bench: PREFIX swrc: SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:month) } /////////////////////////////////////////////////////////// (Q3c) /* * Select all articles with property 'swrc:isbn'. */ PREFIX rdf: PREFIX swrc: PREFIX bench: SELECT ?article WHERE { ?article rdf:type bench:Article . ?article ?property ?value FILTER (?property=swrc:isbn) } /////////////////////////////////////////////////////////// (Q4) /* * Select all distinct pairs of article author names for * authors that have published in the same journal. */ PREFIX rdf: PREFIX bench: PREFIX dc: PREFIX dcterms: PREFIX foaf: PREFIX swrc: 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 PREFIX foaf: PREFIX bench: PREFIX dc: 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) } /////////////////////////////////////////////////////////// (Q5b) /* * Return the names of all persons that occur as author * of at least one inproceeding and at least one article * (same as (Q5a)). */ PREFIX rdf: PREFIX foaf: PREFIX bench: PREFIX dc: 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 } /////////////////////////////////////////////////////////// (Q6) /* * Return, for each year, the set of all publications authored * by persons that have not published in years before. */ PREFIX rdf: PREFIX rdfs: PREFIX foaf: PREFIX dc: PREFIX dcterms: 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 PREFIX rdfs: PREFIX foaf: PREFIX dc: PREFIX dcterms: 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)) } /////////////////////////////////////////////////////////// (Q8) /* * Compute authors that have published with 'Paul Erdoes', * or with an author that has published with 'Paul Erdoes'. */ PREFIX xsd: PREFIX rdf: PREFIX foaf: PREFIX dc: 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) } } /////////////////////////////////////////////////////////// (Q9) /* * Return incoming and outcoming properties of persons. */ PREFIX rdf: PREFIX foaf: SELECT DISTINCT ?predicate WHERE { { ?person rdf:type foaf:Person . ?subject ?predicate ?person } UNION { ?person rdf:type foaf:Person . ?person ?predicate ?object } } /////////////////////////////////////////////////////////// (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". */ PREFIX person: SELECT ?subject ?predicate WHERE { ?subject ?predicate person:Paul_Erdoes } /////////////////////////////////////////////////////////// (Q11) /* * Return (up to) 10 electronic edition URLs starting from the * 51th publication, in lexicographical order. */ PREFIX rdfs: SELECT ?ee WHERE { ?publication rdfs:seeAlso ?ee } ORDER BY ?ee LIMIT 10 OFFSET 50 /////////////////////////////////////////////////////////// (Q12a) /* * Return 'yes' if a person occurs as author of at least one * inproceeding and article, 'no' otherwise. This query is * the boolean counterpart of (Q5a). */ PREFIX rdf: PREFIX foaf: PREFIX bench: PREFIX dc: ASK { ?article rdf:type bench:Article . ?article dc:creator ?person1 . ?inproc rdf:type bench:Inproceedings . ?inproc dc:creator ?person2 . ?person1 foaf:name ?name1 . ?person2 foaf:name ?name2 FILTER (?name1=?name2) } /////////////////////////////////////////////////////////// (Q12b) /* * Return 'yes' if an author has published with 'Paul Erdoes' * or with an author that has published with 'Paul Erdoes', and 'no' * otherwise. This query is the boolean counterpart of (Q8). */ PREFIX xsd: PREFIX rdf: PREFIX foaf: PREFIX dc: ASK { ?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) } } /////////////////////////////////////////////////////////// (Q12c) /* * Check if the person 'John Q Public' exists in the database. */ PREFIX rdf: PREFIX person: PREFIX foaf: ASK { person:John_Q_Public rdf:type foaf:Person. }