DOC PREVIEW
UT Dallas SE 5V81 - SPARQL Query Practice

This preview shows page 1-2-3 out of 8 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 8 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Chapter 3 A Semantic Web Primer1SPARQL Graph PracticeJeffrey PartykaTo try these queries yourself and see their results, import the class SimpsonsSPARQL into an Eclipse project. Then put simpsons.rdf at the top level of your project.3Query #1: Get all triplesPREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?subj ?pred ?obj WHERE { ?subj ?pred ?obj . }4Query #2: Get all triples with simpsons:Homer as the subjectPREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?pred ?obj WHERE { <simpsons:Homer> ?pred ?obj . }5Query #3: Get the surnames of all people that Bart knowsPREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?surname WHERE { <simpsons:Bart> foaf:knows ?person . ?person foaf:surname ?surname . }6Query #4: Get all Simpsons characters with an age > 10PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?person WHERE { ?person ppl:hasAge ?age . FILTER(xsd:integer(?age) > 10) }7Query #5: For each person that is of rdf:type foaf:Person, get their name and the school they attendPREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?name ?school WHERE { ?person rdf:type <foaf:Person> ; foaf:name ?name ; ppl:attendsSchool ?school . }8Query #6: Get the names of Marge’s sisters (blank node practice)PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX simpsons: <http://www.simpsons.com/simpsons/> PREFIX ppl: <http://www.randompeople.com/ppl/> PREFIX job: <http://www.job.com/job/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?sisterName WHERE { <simpsons:Marge> ppl:hasSister ?bn . ?bn ?pred ?sister . ?sister foaf:name ?sisterName .


View Full Document

UT Dallas SE 5V81 - SPARQL Query Practice

Download SPARQL Query Practice
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view SPARQL Query Practice and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view SPARQL Query Practice 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?