
Exercise 1: PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name WHERE { ?person foaf:name ?name . } Exercise 2: PREFIX db: <http://dbpedia.org/resource/> PREFIX onto: <http://dbpedia.org/ontology/> SELECT * WHERE { {?s onto:birthPlace db:Liverpool} UNION {?s onto:deathPlace db:Liverpool} } Exercise 3: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { ?movie a <http://dbpedia.org/ontology/Film> . ?movie rdfs:label ?label . FILTER (lang(?label) = 'en') } LIMIT 10 Exercise 4: PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX dbpprop: <http://dbpedia.org/property/> SELECT DISTINCT ?country ?cnt WHERE { ?country a dbpedia-owl:Country . ?country dbpprop:populationCensus ?cnt } ORDER BY DESC(?cnt) LIMIT 5 [NOTE: we have empirically verified that using the „population“ property instead of „populationCensus“ gives meaningless results; even worst if we look for resources that are „PopulatedPlace“, and we look for their „populationTotal“] Exercise 5: PREFIX s: <http://schema.org/> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbr: <http://dbpedia.org/resource/> SELECT * WHERE { ?hotel a s:Hotel . {?hotel dbo:location dbr:Milan} UNION {?hotel dbo:location dbr:Venice} . OPTIONAL { ?hotel dbp:website ?website } } [NOTE: using dbo:Hotel gives poor results] Exercise 6: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbpedia: <http://dbpedia.org/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbc: <http://dbpedia.org/resource/Category:> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?c WHERE { ?s dcterms:subject dbc:States_of_the_United_States . ?s dbo:capital ?c . } ORDER BY asc(?c) [NOTE: another reasonable possibility would seem to be using the resource http://dbpedia.org/ontology/Capital (subclass of dbo:City), but unfortunately it seems that there are no instances therein] Exercise 7: PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> ASK { dbpedia:Guardians_of_the_Galaxy_Vol._2 dbpedia-owl:starring dbpedia:Chris_Pratt . } Exercise 8: PREFIX prop: <http://dbpedia.org/property/> ASK { <http://dbpedia.org/resource/Amazon_River> prop:length ?amazon . <http://dbpedia.org/resource/Nile> prop:length ?nile . FILTER(?amazon > ?nile) . } Exercise 9: PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX res: <http://dbpedia.org/resource/> ASK { res:Google dbo:numberOfEmployees ?numberGoogle . res:Facebook dbo:numberOfEmployees ?numberFacebook . FILTER(?numberGoogle > ?numberFacebook) } Exercise 10: PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX res: <http://dbpedia.org/resource/> ASK { res:Google dbo:locationCity ?location . res:Google dbo:numberOfEmployees ?numberGoogle . ?company dbo:locationCity ?location . ?company dbo:numberOfEmployees ?numberCompany . FILTER(?numberCompany > ?numberGoogle) } Exercise 11a: PREFIX : <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbc: <http://dbpedia.org/resource/Category:> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX dbp: <http://dbpedia.org/property/> SELECT ?name, ?birthDate WHERE { ?nobel dcterms:subject dbc:Nobel_laureates_in_Physics . ?nobel dbo:birthDate ?birthDate . ?nobel dbp:name ?name . } Exercise 11b: PREFIX : <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbc: <http://dbpedia.org/resource/Category:> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX dbp: <http://dbpedia.org/property/> SELECT ?name, ?birthDate, ?deathDate WHERE { ?nobel dcterms:subject dbc:Nobel_laureates_in_Physics . ?nobel dbo:birthDate ?birthDate . ?nobel dbo:deathDate ?deathDate . ?nobel dbp:name ?name . } ORDER BY asc(?birthDate) Exercise 11c: PREFIX : <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbc: <http://dbpedia.org/resource/Category:> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX dbp: <http://dbpedia.org/property/> SELECT ?nobel, ?name, ?birthDate, ?deathDate WHERE { ?nobel dcterms:subject dbc:Nobel_laureates_in_Physics . ?nobel dbo:birthDate ?birthDate . ?nobel dbp:name ?name . OPTIONAL { ?nobel dbo:deathDate ?deathDate } } ORDER BY asc(?birthDate) Exercise 12: PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX : <http://dbpedia.org/resource/> SELECT ?name ?birth ?death ?person WHERE { ?person dbo:birthPlace :Berlin . ?person dbo:birthDate ?birth . ?person foaf:name ?name . ?person dbo:deathDate ?death . FILTER (?birth < "1900-01-01"^^xsd:date) . } ORDER BY ?name [NOTE: better also converting ?birth into xsd:date, since in some triples it's something different, leading to wrong results] Exercise 13: PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX res: <http://dbpedia.org/resource/> CONSTRUCT { ?company1 dbo:biggerThan ?company2 . ?company2 dbo:smallerThan ?company1 . } WHERE { ?company1 dbo:numberOfEmployees ?employees1. ?company2 dbo:numberOfEmployees ?employees2 . FILTER(?employees1 > ?employees2) } LIMIT 100 Exercise 14: ………… Exercise 15: PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT ?label1 ?genre ?distributor WHERE { SERVICE <http://data.linkedmdb.org/sparql> { SELECT DISTINCT ?label1 ?genre WHERE{ ?movie1 rdf:type movie:film . ?movie1 rdfs:label ?label1 . ?movie1 movie:genre ?genre . ?genre movie:film_genre_name ?genreName . FILTER(?genreName = "Action") } LIMIT 10 } SERVICE <http://dbpedia.org/sparql> { SELECT DISTINCT ?label2 ?distributor WHERE{ ?movie2 a <http://dbpedia.org/ontology/Film> . ?movie2 rdfs:label ?label2 . OPTIONAL {?movie2 dbo:distributor ?distributor} } LIMIT 10 } FILTER(?label1 = ?label2) } Exercise 16: PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?label1 ?distributor ?countryMovie ?countryDistributor WHERE { SERVICE <http://data.linkedmdb.org/sparql> { SELECT DISTINCT ?label1 ?countryMovie WHERE{ ?movie1 rdf:type movie:film . ?movie1 rdfs:label ?label1 . ?movie1 movie:country ?country . ?country movie:country_name ?countryMovie . } LIMIT 10 } SERVICE <http://dbpedia.org/sparql> { SELECT DISTINCT ?label2 ?distributor ?countryDistributor WHERE{ ?movie2 a <http://dbpedia.org/ontology/Film> . ?movie2 rdfs:label ?label2 . ?movie2 dbo:distributor ?distributor . ?distributor dbo:location ?location . ?location foaf:name ?countryDistributor } LIMIT 10 } FILTER(?label1 = ?label2 && ?countryMovie = ?countryDistributor) }.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages5 Page
-
File Size-