Semantic Web                                  TechnologiesLecture 3: Semantic Web - Basic Architecture II                 ...
2Lecture 3: Semantic Web - Basic Architecture II                      Open HPI - Course: Semantic Web Technologies    Sema...
cie nt for                               (S) s uffi        tat ion                      Is R  DF         pre sen           ...
Semantic Web Basic Architecture4     Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Pot...
A Query Language for RDF    • How do we access the knowledge from RDF/RDFS Knowledge Bases?5     • Manual Parsing/Reading ...
A Query Language for RDF    • How do we access the knowledge from RDF/RDFS Knowledge Bases?5     • Manual Parsing/Reading ...
6          • SPARQL 1.0 allows            • Extraction of data as               • URIs, Blank Nodes, typed and untyped Lit...
7          • SPARQL 1.1 (in progress) allows            • additional query features               • aggregate functions, s...
8                SPARQL 1.0    Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
9                • SPARQL Variables are bound to RDF terms                  • e.g. ?journal, ?disease, ?price             ...
SPARQL Query10                                              SELECT ?title ?author ?published                              ...
11                 Graph Pattern                 • SPARQL is based on RDF Turtle serialization and                   basic...
12                                           Triple Pattern                                          ?country geo:capital ...
13     Graph Pattern     • More Examples:      • Given a FOAF URI, find the name of a person:        <http://hpi-web.de/id#...
14   Complex Query Pattern     • Graph Pattern can be combined to form complex (conjunctive) queries       for RDF graph t...
15          SPARQL Query Format              • inspired by SQL                                     SELECT ?p ?o           ...
SPARQL Query Format16            • Search all lectures and their managers:              PREFIX hpi: <http://hpi-web.de/swt...
17               SPARQL Query Format               • Search all lectures and their managers ordered by managers in        ...
18                   Blank Nodes in SPARQL Queries                   • as subject or object of a triple pattern           ...
How should I know all those prefixes?19     Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universit...
cie nt for                               (S) s uffi        tat ion                      Is R  DF         pre sen           ...
Upcoming SlideShare
Loading in...5
×

OpenHPI 3.1 - How to Query RDF(S)? - SPARQL

835

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
835
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
46
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

OpenHPI 3.1 - How to Query RDF(S)? - SPARQL

  1. 1. Semantic Web TechnologiesLecture 3: Semantic Web - Basic Architecture II 01: SPARQL (1) Dr. Harald Sack Hasso Plattner Institute for IT Systems Engineering University of Potsdam Spring 2013 This file is licensed under the Creative Commons Attribution-NonCommercial 3.0 (CC BY-NC 3.0)
  2. 2. 2Lecture 3: Semantic Web - Basic Architecture II Open HPI - Course: Semantic Web Technologies Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  3. 3. cie nt for (S) s uffi tat ion Is R DF pre sen ge Re b? o wl ed ntic We Kn ma Se ? - SPARQL in the 01 How to query RDF(S)Open HPI - Course: SemanticHarald Sack, Hasso-Plattner-Institut, Universität Potsdam Semantic Web Technologies , Dr. Web Technologies - Lecture 3: Semantic Web Basic Architecture
  4. 4. Semantic Web Basic Architecture4 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  5. 5. A Query Language for RDF • How do we access the knowledge from RDF/RDFS Knowledge Bases?5 • Manual Parsing/Reading and Combination of RDF-Triple is complex • Can you imagine a relational database without SQL? Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  6. 6. A Query Language for RDF • How do we access the knowledge from RDF/RDFS Knowledge Bases?5 • Manual Parsing/Reading and Combination of RDF-Triple is complex • Can you imagine a relational database without SQL? • SPARQL Protocol and RDF Query Language ist • a Query Language for RDF Graph Traversal (SPARQL Query Language Specification) • a Protocol Layer, to use SPARQL via http (SPARQL Protocol for RDF Specification) • an XML Output Format Specification for SPARQL Queries (SPARQL Query XML Results Format) • W3C Standard (SPARQL 1.0 since Januar 2008) • inspired by SQL Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  7. 7. 6 • SPARQL 1.0 allows • Extraction of data as • URIs, Blank Nodes, typed and untyped Literals. • RDF Subgraphs • Exploration of Data via Query for unknown relations • Execution of complex Join Operations on heterogeneous databases in a single query • Transformation of RDF Data from one vocabulary into another • Construction of new RDF Graphs based on RDF Query Graphs Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  8. 8. 7 • SPARQL 1.1 (in progress) allows • additional query features • aggregate functions, subqueries, negations, project expressions, property paths • enables logical Entailment for • RDF, RDFS, OWL Direct and RDF-Based Semantics entailment, and RIF Core entailment. • enables Update of RDF Graphs as a full data manipulation language • enables the Discovery of information about the SPARQL service • enables Federated Queries distributed over different SPARQL endpoints Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  9. 9. 8 SPARQL 1.0 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  10. 10. 9 • SPARQL Variables are bound to RDF terms • e.g. ?journal, ?disease, ?price • In the same way as in SQL a Query for variables is performed via SELECT statement • e.g. SELECT ?title ?author ?published • A SELECT statement returns Query Results as a table ?title ?author ?published 1984 George Orwell 1948 Brave New World Aldous Huxley 1932 Fahrenheid 451 Ray Bradbury 1953 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  11. 11. SPARQL Query10 SELECT ?title ?author ?published SPARQL Endpoint ?title ?author ?published 1984 George Orwell 1948 Brave New World Aldous Huxley 1932 Fahrenheid 451 Ray Bradbury 1953 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  12. 12. 11 Graph Pattern • SPARQL is based on RDF Turtle serialization and basic graph pattern matching. • A Graph Pattern (Triple Pattern) is a RDF Triple that contains variables at any arbitrary place (Subject, Predicate, Object). • (Graph) Triple Pattern = Turtle + Variables • Example: • Look for countries and their capitals: ?country geo:capital ?capital . Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  13. 13. 12 Triple Pattern ?country geo:capital ?capital . RDF Graph dbpedia:Venezuela rdf:type dbpedia-owl:Country . dbpedia:Venezuela geo:capital “Caracas“ . dbpedia:Venezuela dbprop:language “Spanish“ . dbpedia:Germany rdf:type dbpedia-owl:Country . dbpedia:Germany geo:capital “Berlin“ . dbpedia:Germany dbprop:language “German“ . ... Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  14. 14. 13 Graph Pattern • More Examples: • Given a FOAF URI, find the name of a person: <http://hpi-web.de/id#haraldsack> foaf:name ?surname . • Which persons have the family name „Schmidt“? ?person pers:familyName “Schmidt“ . Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  15. 15. 14 Complex Query Pattern • Graph Pattern can be combined to form complex (conjunctive) queries for RDF graph traversal. • Find countries, their capitals and their population: ?country geo:capital ?capital . ?country geo:population ?population . • Given a FOAF URI, find the name of a person and her friends: <http://hpi-web.de/id#haraldsack> foaf:name ?surname ; foaf:knows ?friend . ?friend foaf:name ?friend_surname . Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  16. 16. 15 SPARQL Query Format • inspired by SQL SELECT ?p ?o WHERE { <subject> ?p ?o. } • Triple in „WHERE“ part defines graph query with variables ?p and ?o • Query returns table with matching ?p, ?o pairs query answers ?p ?o ?p ?o subject ?p ?o ?p ?o Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  17. 17. SPARQL Query Format16 • Search all lectures and their managers: PREFIX hpi: <http://hpi-web.de/swt1213#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?lecture ?manager FROM <...> WHERE { ! ?x rdf:type hpi:Lecture . ! ?x rdfs:label ?lecture . ! ?y rdf:type hpi:Staff . ! ?y rdfs:label ?manager! ! ?x hpi:isManagedBy ?y . } • WHERE - specifies graph pattern to be matched • PREFIX - specifies one or more namespaces for using compact URIs (CURIEs) • FROM - specifies one or more RDF source graphs • BASE - defines a base URI Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  18. 18. 17 SPARQL Query Format • Search all lectures and their managers ordered by managers in descending order and limit the results to the first 10 starting the list at position 10: PREFIX hpi: <http://hpi-web.de/swt1213#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?lecture ?manager FROM <...> WHERE { ! ?x rdf:type hpi:Lecture ; ! rdfs:label ?lecture . ! ?y rdf:type hpi:Staff ; ! rdfs:label ?manager! ! ?x hpi:isManagedBy ?y . } ORDER BY DESC (?manager) LIMIT 10 OFFSET 10 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  19. 19. 18 Blank Nodes in SPARQL Queries • as subject or object of a triple pattern • „non selectable“ variables PREFIX hpi: <http://hpi-web.de/swt1213#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name WHERE { ! _:x rdf:type hpi:Lecture ; ! hpi:isManagedBy [rdfs:label ?name] . } • blank node identifier might also occur in the results Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  20. 20. How should I know all those prefixes?19 Semantic Web Technologies , Dr. Harald Sack, Hasso-Plattner-Institut, Universität Potsdam
  21. 21. cie nt for (S) s uffi tat ion Is R DF pre sen ge Re b? o wl ed ntic We Kn ma Se ? - SPARQL (2) 02 How toin theRDF(S) queryOpen HPI - Course: SemanticHarald Sack, Hasso-Plattner-Institut, Universität Semantic Web Basic Architecture Semantic Web Technologies , Dr. Web Technologies - Lecture 3: Potsdam
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×