Presentation is loading. Please wait.

Presentation is loading. Please wait.

SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014.

Similar presentations


Presentation on theme: "SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014."— Presentation transcript:

1 SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014

2 Ontologies so far: RDF O RDF: a conceptual approach to representing data as triples: subject – predicate – object. It’s a family of specifications, where… O Classes and properties vary: rdf vs rdfs O Various data serialisation formats: - RDF/XML - Turtle - JSON-LD, etc.

3 OWL O A family of ontology languages with clearly defined semantics O Syntax of: OWL Lite ⊂ OWL DL ⊂ OWL Full O OWL Lite meant to restrict constructs for comp. efficiency, but expressiveness (hence complexity) ≈ OWL DL, just more awkward. O OWL DL: tailored to be a complete and decidable logic, with practical reasoning algs

4 OWL 2 O Introduces 3 subsets of the language: - EL – polynomial time reasoning complexity - QL – tailored to work with databases - RL - a rule subset of OWL2

5 Abstract syntax vs. serialisation O At the most abstract level one uses the notation of the appropriate class of logic O This can be saved in a variety of ways, e.g. see Protégé menu:

6 Ease of reading and expressivity can vary: O OWL2 Functional Syntax: Ontology( Declaration( Class( :Pop ) )) O RDF/XML syntax: O RDF/Turtle rdf:type owl:Ontology. :Pop rdf:type owl:Class.

7 (cont.) O Manchester Syntax: Ontology: Class: Pop ______________________________________ These details are hidden away when using a GUI tool, such as Protégé, to implement the ontology. It’s still important to understand the abstract syntax, which appears in the GUI, e.g. Student ⊑ Person (a description) Father ≡ Man ⊓ Parent (a definition) _______________________________________

8 OWL abstract syntax e.g. here is a subset:

9 Protégé 3.x vs 4.x O Use 3.x if application cannot abstract away from working directly with the RDF triples; or to have built-in support for SPARQL to query the database. Multi-user support, database storage possible. Supports OWL1.0 (DL, OWL Full possible.) O Use 4.x to work in pure OWL (2.0), with better optimisations of parser and memory use. No SPARQL, no DB support, no multi-u.

10 Building an ontology with Protégé: a case study Student ⊑ Person Lecturer ⊑ Person Student ⊓ Lecturer ≡ ⊥ ( i.e.: disjoint(Student,Lecturer) ) CSModule ⊑ Module MathsModule ⊑ Module CSModule ⊓ MathsModule ≡ ⊥

11 Building an ontology with Protégé: a case study Object properties: Studies Domain = Student; Range = Module Teaches Domain = Lecturer; Range = Module Data properties: Mapping individuals to values (strings for names and acronyms, integers for student ID.)

12

13 Publishing the ontology O Choose the URL where the file will be placed from the start and enter it in Protégé; O Put the file at that URL (e.g. home Web dir) when ready.

14 SPARQL Queries O A query language for ontologies O Protégé 3.x has built-in support (not in 4.x) O We’ll save our DB in RDF/XML format… O …then use the Apache Jena-Fuseki SPARQL servlet to access it.

15 Apache Jena-Fuseki O Serving RDF data over HTTP O Supports SPARQL for querying and updating O Get from - jena-fuseki distribution.tar.gz - tar –zxf - cd jena-fuseki /fuseki-server -update --mem /ds - open a browser and go to localhost:3030

16 Apache Jena-Fuseki - Control panel -> /ds [Select] - File upload (to upload you local DB) - you can then use SPARQL, e.g. SELECT * WHERE {?x ?y ?z} to see the entire DB.

17 SPARQL queries

18

19 More examples O What does this do? PREFIX uni: SELECT ?student WHERE {?student uni:Studies uni:CS101}

20 More examples O What does this do? PREFIX uni: PREFIX rdfs: SELECT ?class WHERE {?class rdfs:subClassOf uni:Person}


Download ppt "SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014."

Similar presentations


Ads by Google