1 / 71

CC7220-1 La Web de Datos Primavera 2018 Lecture 8: SPARQL [ 1 .1]

CC7220-1 La Web de Datos Primavera 2018 Lecture 8: SPARQL [ 1 .1]. Aidan Hogan aidhog@gmail.com. Previously …. First SPARQL (1.0) Then SPARQL 1.1. Covered SPARQL 1.0. http://www.w3.org/TR/rdf-sparql-query /. Today: SPARQL 1.1. A Web standard. http:// www.w3.org/TR/sparql11-query/.

cassandrat
Download Presentation

CC7220-1 La Web de Datos Primavera 2018 Lecture 8: SPARQL [ 1 .1]

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CC7220-1La Web de DatosPrimavera 2018Lecture 8: SPARQL [1.1] Aidan Hogan aidhog@gmail.com

  2. Previously …

  3. First SPARQL (1.0) Then SPARQL 1.1

  4. Covered SPARQL 1.0 http://www.w3.org/TR/rdf-sparql-query/

  5. Today: SPARQL 1.1

  6. A Web standard http://www.w3.org/TR/sparql11-query/

  7. What’s new in SPARQL 1.1? • New query features • An update language • Support for RDFS/OWL entailment • New output formats

  8. Query feature: Negation

  9. SPARQL 1.0: Negation possible w/ a trick! Query: What solutions would this query return? Solutions: Can do a closed-world style of negation!

  10. SPARQL 1.1: (NOT) EXISTS Query: Solutions:

  11. SPARQL 1.1: MINUS Query: Solutions:

  12. Difference between MINUS and NOTEXISTS?

  13. Difference between MINUS and NOTEXISTS? • NOT EXISTS: Returns results if right hand side has no matches • MINUS: Removes solutions from the left hand side that would join with the right hand side

  14. Difference between MINUS and NOTEXISTS? There is no join between the results! Therefore nothing removed! There is a match! Therefore no results!

  15. New query feature: Property paths

  16. Property paths: regular expressions Only these features cannot be rewritten to something else. These features are “new”, offering arbitrary length paths!

  17. Property paths example: RDF list How to ask: “Which movies are in the Sharknado series?” Query: Solutions:

  18. Property paths example: Finite Bacon number How to ask: “Who has a finite Bacon number?” Query: Solutions: We cannot get the actual Bacon number (path length) for arbitrary length paths

  19. New query feature: Assignment

  20. Assignment with BIND Query: Solutions:

  21. Assignment with VALUES Query: Solutions: No result for ex:Sharknadoex:IanZiering!

  22. New query feature: Aggregates

  23. Aggregates How to ask: “How many movie stars are in the data?”

  24. Aggregates: COUNT Query: Solutions:

  25. Aggregates: COUNT Query: Solutions: DISTINCT applied after COUNT!

  26. Aggregates: COUNT Query: Solutions:

  27. Aggregates How to ask: “How many stars does each movie have?”

  28. Aggregates: COUNT with GROUP BY Query: Solutions:

  29. Aggregates How to ask: “Give me movies with more than 1 star?”

  30. Aggregates: COUNT, GROUP BY, HAVING Query: Solutions: HAVINGis like a FILTERfor aggregates

  31. Aggregates in SPARQL 1.1 • COUNT: Count values • SUM: Sum a set of values • MIN: Find the lowest value • MAX: Find the highest value • AVG: Get the average of values • GROUP_CONCAT: String-concat values • SAMPLE: Select a value (pseudo-randomly)

  32. One more aggregates example: SAMPLE Query: Solutions: OR

  33. Quick note on semantics

  34. Recall from OWL: OWA and lack of UNA

  35. Looks like SPARQL has a UNA and a CWA … But SPARQL does not have “worlds”. It does not interpret “real people”. SPARQL works on data. SPARQL counts RDF terms, not children. But in SPARQL … Query: ex:Vito :hasChild ex:Connie ex:Sonny ex:Fredo ex:Michael Solutions:

  36. New query feature: Subqueries

  37. Subqueries How to ask: “How many stars does a movie have on average?”

  38. Subqueries Query: Solutions: Sub-queries useful when you need solution modifiers or aggregates in the middle of a more complex query.

  39. Subqueries How to ask: “Which movies have more stars than average?”

  40. Subqueries Query: Solutions: We use ?avg in HAVING clause but it's not part of the GROUP BY

  41. Subqueries Query: Solutions: ?movie in the sub-query is not correlated with ?movie in the outmost query

  42. New query feature: Federation

  43. Endpoints often made public/online

  44. Federation: execute sub-query remotely Get actors for Star Trek movie from LinkedMDB. Use DBpedia to get the birthdate of the actor Can be run at http://sparql.org/sparql.html Example borrowed from: http://www.cambridgesemantics.com/semantic-university/sparql-by-example

  45. New language: SPARQL 1.1 Update

  46. What’s new in SPARQL 1.1? • New query features • An update language • Support for RDFS/OWL entailment • New output formats

  47. INSERT DATA default graph

  48. INSERT DATA named graph

  49. DELETE DATA

  50. INSERT/DELETE with WHERE

More Related