Presentation is loading. Please wait.

Presentation is loading. Please wait.

SPARQL Exercise Most of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3 http://www.uio.no/studier/emner/matnat/ifi/INF3580/v15/undervisningsmateriale/oblig3.pdf.

Similar presentations


Presentation on theme: "SPARQL Exercise Most of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3 http://www.uio.no/studier/emner/matnat/ifi/INF3580/v15/undervisningsmateriale/oblig3.pdf."— Presentation transcript:

1 SPARQL Exercise Most of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3

2 Copy the Turtle defined ontology on next slide to an ”
Copy the Turtle defined ontology on next slide to an ”.owl” file and load it into Protégé.

3 @prefix : <http://www. simpsons. no/simpsonsfamily#>
@prefix : < foaf: < owl: < rdf: < xml: < xsd: < rdfs: < . < rdf:type owl:Ontology . ################################################################# # # Object Properties :hasBrother rdf:type owl:ObjectProperty . :hasParent rdf:type owl:ObjectProperty . :hasSister rdf:type owl:ObjectProperty . :hasUncle rdf:type owl:ObjectProperty . :hasFamilyMember rdf:type owl:ObjectProperty . :hasSpouse rdf:type owl:ObjectProperty . :hasFather rdf:type owl:ObjectProperty . :hasMother rdf:type owl:ObjectProperty . # Data properties :birthday rdf:type owl:DatatypeProperty ; rdfs:range xsd:dateTime . :diedOn rdf:type owl:DatatypeProperty ; :hasName rdf:type owl:DatatypeProperty ; rdfs:range xsd:string . # Classes :Family rdf:type owl:Class . :Man rdf:type owl:Class ; rdfs:subClassOf foaf:Person . :Woman rdf:type owl:Class ; #################################################################### :Homer a foaf:Person ; foaf:age "36"^^xsd:int ; foaf:name "Homer Simpson" . :Marge foaf:age "34"^^xsd:int ; foaf:name "Marge Simpson" . :Lisa foaf:age "8"^^xsd:int ; foaf:name "Lisa Simpson" . :Bart foaf:age "10"^^xsd:int ; foaf:name "Bart Simpson" . :Maggie foaf:age "1"^^xsd:int ; foaf:name "Maggie Simpson" . :Simpsons a :Family ; :hasFamilyMember :Maggie , :Homer , :Lisa , :Bart, :Marge . :hasSpouse :Marge . :hasSpouse :Homer . :hasFather :Homer ; :hasMother :Marge . :Abraham a foaf:Person . :hasParent [ a foaf:Person ; :hasFather :Abraham ] . :Mona a foaf:Person . :hasMother :Mona :hasSister :Patty , :Selma ] ; :hasBrother :Herb :Herb a foaf:Person . :Patty a foaf:Person ; :hasSister :Selma . :Selma :hasSister :Patty . :hasSpouse

4 Task 1 Query: Find all Persons and order them by identifier, list also optionally their name. Use the result variable names ?person, ?name . Tip: This is a simple query, where you will need to use SELECT, WHERE, OPTIONAL and ORDER BY . If you do not get any results, try the query SELECT ?s ?p ?o WHERE {?s ?p ?o} and see if your get the expected results and namespaces. This query lists all triples in the graph.

5 Task 2 Query: Find everyone who has a mother and list both the person and the mother. Order by mother.

6 Task 3 Query: Find everyone who has a mother or a father and list both the person and the mother or father. Order by mother/father.

7 Task 4 Query: Find all of Maggie’s grandmothers. Result variable name: ?grandmother .

8 Task 5 Query: Find everyone older than 10. Order by age, oldest first. Output name and age. Result variable names: ?person, ?age .

9 Task 6 Query: Is Herb the brother of Homer? (We know Homer has a brother named Herb, but here the question is: Do the ontology contain this information?) Tip: Use ASK .


Download ppt "SPARQL Exercise Most of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3 http://www.uio.no/studier/emner/matnat/ifi/INF3580/v15/undervisningsmateriale/oblig3.pdf."

Similar presentations


Ads by Google