Master Informatique 1 Semantic Technologies Part 7SPARQL 1.1 Werner Nutt.

Slides:



Advertisements
Similar presentations
Advanced SQL (part 1) CS263 Lecture 7.
Advertisements

XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 SQL: Queries, Programming, Triggers Chapter 5 Modified by Donghui Zhang.
 Copyright 2004 Digital Enterprise Research Institute. All rights reserved. SPARQL Query Language for RDF presented by Cristina Feier.
SPARQL RDF Query.
E-R Diagram for a Banking Enterprise
FALL 2004CENG 351 File Structures and Data Management1 SQL: Structured Query Language Chapter 5.
Nov 24, 2003Murali Mani SQL B term 2004: lecture 12.
--The SQL Query Language DML--1 LIKE  LIKE allows to select character strings which have some element in common by using wild cards:  Wild cards:  “%”
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. SQL - part 2 - Database Management Systems I Alex Coman, Winter 2006.
Master Informatique 1 Semantic Technologies Part 3RDF/XML: Encoding RDF into XML Werner Nutt.
Chapter 3A Semantic Web Primer 1 Chapter 3 Querying the Semantic Web Grigoris Antoniou Paul Groth Frank van Harmelen Rinke Hoekstra.
Logics for Data and Knowledge Representation SPARQL Protocol and RDF Query Language (SPARQL) Feroz Farazi.
More on SPARQL. Acknowledgements This presentation is based on the W3C Candidate Recommendation “SPARQL Query Language for RDF” (
Master Informatique 1 Semantic Technologies Part 6Semantics of SPARQL Werner Nutt.
SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link:
Master Informatique 1 Semantic Technologies Part 5SPARQL Werner Nutt.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 3: Introduction.
Introduction to SPARQL. Acknowledgements This presentation is based on the W3C Candidate Recommendation “SPARQL Query Language for RDF” from
SPARQL Semantic Web - Spring 2008 Computer Engineering Department Sharif University of Technology.
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall Querying on the Web: XQuery, RDQL, SparQL Semantic Web.
1 ICS 184: Introduction to Data Management Lecture Note 10 SQL as a Query Language (Cont.)
SPARQL W3C Simple Protocol And RDF Query Language
SQL: Data Manipulation Presented by Mary Choi For CS157B Dr. Sin Min Lee.
SPARQL AN RDF Query Language. SPARQL SPARQL is a recursive acronym for SPARQL Protocol And Rdf Query Language SPARQL is the SQL for RDF Example: PREFIX.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Using Special Operators (LIKE and IN)
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
ONTOLOGY ENGINEERING Lab #6 – October 6, The FILTER Keyword  Up to this point we’ve restricted the result set of a query by binding a variable.
SQL SeQueL -Structured Query Language SQL SQL better support for Algebraic operations SQL Post-Relational row and column types,
1 XML Data Management XPath Principles Werner Nutt.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Extended Relational-Algebra-Operations Generalized Projection Aggregate Functions Outer Join.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
1 CS 430 Database Theory Winter 2005 Lecture 5: Relational Algebra.
05/01/2016 SPARQL SPARQL Protocol and RDF Query Language S. Garlatti.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 8: SPARQL (1.1) Aidan Hogan
An Effective SPARQL Support over Relational Database Jing Lu, Feng Cao, Li Ma, Yong Yu, Yue Pan SWDB-ODBIS 2007 SNU IDB Lab. Hyewon Lim July 30 th, 2009.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 7: SPARQL (1.0) Aidan Hogan
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
IST 210 More SQL Todd Bacastow IST 210: Organization of Data.
1 SQL: The Query Language. 2 Example Instances R1 S1 S2 v We will use these instances of the Sailors and Reserves relations in our examples. v If the.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Day 5 - More Complexity With Queries Explanation of JOIN & Examples Explanation of JOIN & Examples Explanation & Examples of Aggregation Explanation &
Semantic Web in Depth SPARQL Protocol and RDF Query Language Dr Nicholas Gibbins –
Chapter 11 – Data Manipulation: Relational Algebra and SQL1 Unit 9: Data Manipulation: Relational Algebra and SQL IT238: Data Modeling and Database Design.
CHAPTER SIX T HE P ROBABILISTIC M ETHOD M1 Zhang Cong 2011/Nov/28.
SPARQL Query Andy Seaborne. Apache Jena he.org/jena ● Open source - Apache License ● Apache Incubator (accepted November 2010) ●
CC La Web de Datos Primavera 2017 Lecture 7: SPARQL [i]
CC La Web de Datos Primavera 2017 Lecture 8: SPARQL [ii]
01/31/11 SQL Examples Edited by John Shieh CS3754 Classnote #10.
Semantic Web Services SWS Tutorials.
Introduction to SPARQL
SPARQL SPARQL Protocol and RDF Query Language
SQL: Structured Query Language DML- Queries Lecturer: Dr Pavle Mogin
CS 405G: Introduction to Database Systems
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
CC La Web de Datos Primavera 2016 Lecture 7: SPARQL (1.0)
CS 3630 Database Design and Implementation
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
CS4222 Principles of Database System
G-CORE: A Core for Future Graph Query Languages
SQL: Structured Query Language
Query Functions.
CC La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1]
Presentation transcript:

Master Informatique 1 Semantic Technologies Part 7SPARQL 1.1 Werner Nutt

Master Informatique 2 Semantic Technologies Part 7SPARQL 1.1 Acknowledgment These slides are essentially identical with those by Sebastian Rudolph for his course on Semantic Web Technologies at TU Dresden

Master Informatique 3 Semantic Technologies Part 7SPARQL 1.1 Expressions in the Selection and Bindings Solutions can be extended by evaluated expressions with (expression AS ?var) used for the assignment: in the SELECT clause in the GROUP BY clause within BIND in a group graph pattern Solutions from a group can further be joined with solutions given via a VALUES pattern

Master Informatique 4 Semantic Technologies Part 7SPARQL 1.1 Example BIND (without Prefix Declarations) ex:Book ex:title "SPARQL Tutorial" ; ex:price 42 ; ex:discount 10. SELECT ?title ?price WHERE { ?b ex:title ?title; ex:price ?p ; ex:discount ?r BIND ((?p-?r) AS ?price) } ?title → "SPARQL Tutorial", ?price → 32  Algebra: Extend(Bgp(...), ?price, (?p-?r))

Master Informatique 5 Semantic Technologies Part 7SPARQL 1.1  Algebra: Extend(Bgp(...), ?price, (?p-?r)) Example SELECT Expressions (without Prefix Declarations) ex:Book ex:title "SPARQL Tutorial" ; ex:price 42 ; ex:discount 10. SELECT ?title ((?p-?r) AS ?price WHERE { ?b ex:title ?title; ex:price ?p ; ex:discount ?r } ?title → "SPARQL Tutorial", ?price → 32

Master Informatique 6 Semantic Technologies Part 7SPARQL 1.1  Bindings are conjunctively joined Example VALUES ex:Book1 ex:title "SPARQL Tutorial". ex:Book2 ex:title "SemWeb". SELECT ?title WHERE { ?b ex:title ?title VALUES ?b { ex:Book1 } } ?title → "SPARQL Tutorial”

Master Informatique 7 Semantic Technologies Part 7SPARQL 1.1 Aggregates Aggregates allow for the grouping of solutions and the computation of values over the groups GROUP BY groups the solutions (here into students who attend the same lecture) COUNT is an aggregate function that counts the solutions within a group (here the number of students in the lecture) HAVING filters aggregated values SELECT ?lecture (COUNT(?student) AS ?c) WHERE { ?student ex:attends ?lecture } GROUP BY ?lecture HAVING COUNT(?student) > 5

Master Informatique 8 Semantic Technologies Part 7SPARQL 1.1 Aggregates in SPARQL 1.1 SPARQL 1.1 supports the following aggregate functions, which are evaluated over the values in a group: COUNT – counts the solutions MIN – finds the minimal value MAX – finds the maximal value SUM – sums up the values AVG – computes the average SAMPLE – picks a random value GROUP_CONCAT – string concatenation, Example: GROUP_CONCAT(?x ; separator = ",") Note: Most SPARQL 1.1 implementations only concatenate strings!

Master Informatique 9 Semantic Technologies Part 7SPARQL 1.1 Exercise Aggregates Return those students (with their average marks) that have an average mark > 25. Return the subgraph of the data consisting of students with an average mark > 25 and their marks. Return those that have an average mark > 25 together with a list of their marks, separated by “|”. Show also what you expect to be the solution. ex:Paul ex:hasMark ex:Paul ex:hasMark ex:Mary ex:hasMark ex:Peter ex:hasMark 22.0.

Master Informatique 10 Semantic Technologies Part 7SPARQL 1.1 Subqueries Results for the inner query are conjunctively joined with the results of the outer query SELECT ?name WHERE { ?x foaf:name ?name. { SELECT ?x (COUNT(*) AS ?count) WHERE { ?x foaf:knows ?y. } GROUP BY ?x HAVING (?count >= 3) }

Master Informatique 11 Semantic Technologies Part 7SPARQL 1.1 Negation in Queries Two forms of negation with conceptual and small semantic differences ① Test for non-matches for a pattern ② Removal of matching solutions What are the corresponding constructs in SQL? What is the difference between them in SQL? SELECT ?x WHERE { ?x rdf:type foaf:Person. FILTER NOT EXISTS { ?x foaf:name ?name } } SELECT ?x WHERE { ?x rdf:type foaf:Person. MINUS { ?x foaf:name ?name } }

Master Informatique 12 Semantic Technologies Part 7SPARQL 1.1 Evaluation of Negation via Filter ① [[ Bgp(1 st Pattern) ]] G : μ 1 : ?x → _:x, μ 2 : ?x → _:y ② For each solution, we instantiate the second pattern –Solution is removed if the instantiated pattern matches (μ 1 ) –otherwise we keep the solution (μ 2 ) _:x rdf:type foaf:Person. _:x foaf:name "Peter". _:y rdf:type foaf:Person. { ?x rdf:type foaf:Person. FILTER NOT EXISTS { ?x foaf:name ?name } }

Master Informatique 13 Semantic Technologies Part 7SPARQL 1.1 Evaluation of Negation via Minus [[ Bgp(1 st Pattern) ]] G : Ω 1 = { μ 1 : ?x → _:x, μ 2 : ?x → _:y } [[ Bgp(2 nd Pattern) ]] G : Ω 2 = { μ 3 : ?x → _:x, ?name → "Peter” } Minus(Ω 1, Ω 2 ) = {μ | μ ∈ Ω 1 and ∀ μ′ ∈ Ω 2 : μ and μ′ incompatible or dom(μ) ∩ dom(μ′) = ∅ } μ 1 ! ∈ Ω: μ 1 compatible with μ 3 and has non-disjoint domain μ 2 ∈ Ω: μ 2 incompatible with μ 3 _:x rdf:type foaf:Person. _:x foaf:name "Peter". _:y rdf:type foaf:Person. { ?x rdf:type foaf:Person. MINUS { ?x foaf:name ?name } }

Master Informatique 14 Semantic Technologies Part 7SPARQL 1.1 Minus and Filter Negation: Differences Filter pattern matches always (variables disjoint)  every solution is removed Minus does not remove any solutions since the domain of the solutions is disjoint ex:a ex:b ex:c. { ?s ?p ?o FILTER NOT EXISTS { ?x ?y ?z } } { ?s ?p ?o MINUS { ?x ?y ?z } }

Master Informatique 15 Semantic Technologies Part 7SPARQL 1.1 Regular Expressions in Patterns Property paths are constructed using regular expressions over predicates Sequence of paths: ?s ex:p1/ex:p2 ?o Optional path: ?s ex:p? ?o Paths with arbitrary length: ?s ex:p+ ?o, ?s ex:p* ?o Alternative paths: ?s (ex:p1|ex:p2) ?o Inverse paths: ?s ˆex:p ?o same as ?o ex:p ?s Negation of paths: ?s !ex:p ?o A negation of path expression !ex:p matches a path that does not have predicate ex:p

Master Informatique 16 Semantic Technologies Part 7SPARQL 1.1 Regular Expressions in Patterns Property paths are, where possible, translated into standard SPARQL constructs Examples? Some new operators are still necessary

Master Informatique 17 Semantic Technologies Part 7SPARQL 1.1 Property Path Examples PREFIX... SELECT ?xName WHERE { ?x rdf:type foaf:Person. ?x foaf:name ?xName ?x foaf:knows/foaf:knows/foaf:name "Bill Gates". } PREFIX... SELECT ?s WHERE { ?s rdf:type ?type. ?type rdfs:subClassOf* ex:SomeClass. }