SPARQL W3C Simple Protocol And RDF Query Language

Slides:



Advertisements
Similar presentations
Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
Advertisements

ESDSWG2011 – Semantic Web session Semantic Web Sub-group Session ESDSWG 2011 Meeting – Semantic Web sub-group session Wednesday, November 2, 2011 Norfolk,
RDF Tutorial.
Semantic Web Introduction
© Copyright IBM Corporation 2014 Getting started with Rational Engineering Lifecycle Manager queries Andy Lapping – Technical sales and solutions Joanne.
Information Systems & Semantic Web University of Koblenz ▪ Landau, Germany Semantic Web - Query Languages – Steffen Staab
 Copyright 2004 Digital Enterprise Research Institute. All rights reserved. SPARQL Query Language for RDF presented by Cristina Feier.
SPARQL RDF Query.
SPARQL Nikhil Rajguru. W3C Standards SPARQL Query Language for RDF SPARQL 1.1 Update SPARQL 1.1 Protocol SPARQL 1.1 Graph Store HTTP Protocol SPARQL.
Chapter 3 Querying RDF stores with SPARQL. TL;DR We will want to query large RDF datasets, e.g. LOD SPARQL is the SQL of RDF SPARQL is a language to query.
SPARQL for Querying PML Data Jitin Arora. Overview SPARQL: Query Language for RDF Graphs W3C Recommendation since 15 January 2008 Outline: Basic Concepts.
1 RDF Aggregate Queries and Views Edward Hung, Yu Deng, V.S. Subrahmanian University of Maryland, College Park ICDE 2005, April 7, Tokyo, Japan.
Semantic Web Query Processing with Relational Databases Artem Chebotko Department of Computer Science Wayne State University.
Semantic Web Andrejs Lesovskis. Publishing on the Web Making information available without knowing the eventual use; reuse, collaboration; reproduction.
Semantic Web Bootcamp Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation.
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.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Publishing data on the Web (with.
More on SPARQL. Acknowledgements This presentation is based on the W3C Candidate Recommendation “SPARQL Query Language for RDF” (
1 Ontology Query and Reasoning Payam Barnaghi Institute for Communication Systems (ICS) Faculty of Engineering and Physical Sciences University of Surrey.
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.
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.
Logics for Data and Knowledge Representation
The Semantic Web Web Science Systems Development Spring 2015.
Chapter 3 Querying RDF stores with SPARQL. Why an RDF Query Language? Why not use an XML query language? XML at a lower level of abstraction than RDF.
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall Querying on the Web: XQuery, RDQL, SparQL Semantic Web.
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.
SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link:
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 2: RDF Model & Syntax Aidan Hogan
Master Informatique 1 Semantic Technologies Part 7SPARQL 1.1 Werner Nutt.
RDF and XML 인공지능 연구실 한기덕. 2 개요  1. Basic of RDF  2. Example of RDF  3. How XML Namespaces Work  4. The Abbreviated RDF Syntax  5. RDF Resource Collections.
1 SPARQL A. Emrah Sanön. 2 RDF RDF is quite committed to Semantic Web. Data model Serialization by means of XML Formal semantics Still something is missing!
Semantic Web Basics Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation.
SPARQL In-Class Shared Exercise. Pop Quiz If you have a large knowledge store, why should you not issue: SELECT ?s ?p ?o WHERE { ?s ?p ?o } Ans: It returns.
Dr. Lowell Vizenor Ontology and Semantic Technology Practice Lead Alion Science and Technology Semantic Technology: A Basic Introduction.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
RDFPath: Path Query Processing on Large RDF Graph with MapReduce Martin Przyjaciel-Zablocki et al. University of Freiburg ESWC May 2013 SNU IDB.
05/01/2016 SPARQL SPARQL Protocol and RDF Query Language S. Garlatti.
Doc.: IEEE /0169r0 Submission Joe Kwak (InterDigital) Slide 1 November 2010 Slide 1 Overview of Resource Description Framework (RFD/XML) Date:
Chapter 3 Querying RDF stores with SPARQL
Alexandra Cristea 1.  pronounced "sparkle“  recursive acronym for: ◦ SPARQL Protocol and RDF Query Language  a semantic query language  a query language.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 8: SPARQL (1.1) Aidan Hogan
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.
Knowledge Technologies Manolis Koubarakis 1 Some Other Useful Features of RDF.
Graph and RDF Databases Context : Course of Advanced Databases Prepared by : Nassim BAHRI Nabila HOSNI February 19th, 2015.
Linked Data & Semantic Web Technology The Semantic Web Part 5. Resource Description Framework (2) Dr. Myungjin Lee.
Semantic Web in Depth SPARQL Protocol and RDF Query Language Dr Nicholas Gibbins –
Database Design lecture 3_2 Slide 1 Database Design Lecture 3_2 Data Manipulation in SQL Simple SQL queries References: Text Chapter 8 Oracle SQL Manual.
Setting the stage: linked data concepts Moving-Away-From-MARC-a-thon.
NEDA ALIPANAH, MARIA ADELA GRANDO DBMI 11/19/2012.
SPARQL Query Andy Seaborne. Apache Jena he.org/jena ● Open source - Apache License ● Apache Incubator (accepted November 2010) ●
OWL (Ontology Web Language and Applications) Maw-Sheng Horng Department of Mathematics and Information Education National Taipei University of Education.
Developing Linked Data Applications
Vincenzo Maltese, Fausto Giunchiglia University of Trento
CC La Web de Datos Primavera 2017 Lecture 7: SPARQL [i]
SPARQL.
CC La Web de Datos Primavera 2016 Lecture 8: SPARQL (1.1)
CC La Web de Datos Primavera 2017 Lecture 8: SPARQL [ii]
Introduction to SPARQL
SPARQL SPARQL Protocol and RDF Query Language
SPARQL: A query language for RDF
SPARQL Exercise Much of this exercise has been copied from: INF3580/INF4580 – MANDATORY EXERCISE 3
Logics for Data and Knowledge Representation
CC La Web de Datos Primavera 2016 Lecture 7: SPARQL (1.0)
CC La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1]
XQuery Leonidas Fegaras.
Logics for Data and Knowledge Representation
Presentation transcript:

SPARQL W3C Simple Protocol And RDF Query Language

2 SPARQL W3C RDF Data Access Use Case and Requirements : Query language : XML Result Format: Protocol for Web Services :

3 SPARQL Semantic Web SQL Query an RDF triple store as graph(s) SPARQL is neutral w.r.t inferences RDF/RDFS/OWL/RIF (e.g. subsumption, transitivity, etc.) The triple store may process inferences SPARQL 1.0 does not enable to tune inferences

4 SPARQL : example PREFIX foaf: SELECT ?mbox WHERE { ?x foaf:name ‘Olivier’. ?x foaf:mbox ?mbox } Return the mail box of resources whose name is ‘Olivier’

5 SPARQL Syntax: Triple subject property object foaf:name ?name ?x foaf:name 'Olivier' ?x ?p 'Olivier' _:b1 foaf:age 49

6 Blank Node ?x c:speed [ rdf:value ?val ; c:unit 'km/h' ] Equivalent to : ?x c:speed _:b _:b rdf:value ?val _:b c:unit 'km/h'

7 List Syntax (1 ?x ‘v’)  _:a rdf:first 1. _:a rdf:rest _:b. _:b rdf:first ?x. _:b rdf:rest _:c. _:c rdf:first ‘v’. _:c rdf:rest rdf:nil

8 Filter: Evaluable Expression FILTER (?age >= 7 && ?age <= 77) Comparison : = > != Operation : + * / - Boolean : && (and) || (or) ! (not) Function : isBlank(?x) my:fun(?y)

9 Filter: Evaluable Expression ?x c:age ?age FILTER (?age >= 7 && ?age <= 77) Variable must be bound by a triple

10 Tests Match a regular expression regex(?string, ‘.*inria.*’)

11 Tests Compare literals with and without language “engineer” =

12 Tests : functions isURI(?x) isLiteral(?y) isBlank(?z) bound(?t)

13 Tests : cast xsd:integer(?x) >= 18 xsd:date(“ ”) xsd:string(“ xsd:double() xsd:boolean()

14 Optional Pattern SELECT * WHERE { ?x :hasCreated ?doc. OPTIONAL { ?x :isMemberOf ?org } } hasCreated is mandatory isMemberOf is optional

15 Optional Pattern SELECT * WHERE { ?x :hasCreated ?doc. OPTIONAL { ?x :age ?age. ?x :isMemberOf ?org } age and isMemberOf must be present for the success of optional

16 Optional Pattern SELECT * WHERE { ?x :hasCreated ?doc. OPTIONAL {?x :age ?age} OPTIONAL {?x :isMemberOf ?org} }

17 Pattern UNION SELECT * WHERE { :Francis :apply :Presidency {?x :apply ?job}:Nick :practice :Bike UNION:Nick :apply :Presidency {?x :practice ?act} } R e sults (1) x = :Francis ; job = :Presidency ; act = unbound (2) x = :Nick; job = unbound ; act = :Bike (3) x = :Nick ; job = :Presidency ; act = unbound

18 RDF Dataset Query an RDF base with several graphs Named graphs with URIs Default graph Identify the graphs that are queried

Corese - 19 SPARQL Graph Pattern INRIA Olivier s:in

Corese - 20 SPARQL Graph Pattern INRIA Olivier s:in g1

Corese - 21 SPARQL Graph Pattern INRIA James Olivier s:in CNRS s:in g1 g2

Corese - 22 SPARQL Graph Pattern select ?g where { graph ?g {?x s:in ?org} } INRIA James Olivier s:in CNRS s:in g1 g2

Corese - 23 SPARQL Graph Pattern select ?g where { graph ?g {?x s:in ?org} } INRIA James Olivier s:in CNRS s:in g1 g2 (1) ?g = g1 (2) ?g = g2

Corese - 24 SPARQL Graph Pattern INRIA James Olivier s:in CNRS s:in g1 g2 select * from named where { graph ?g {?x s:in ?org} }

Corese - 25 SPARQL Default Graph INRIA James Olivier s:in CNRS s:in g1 g2 select * from where { ?x s:in ?org }

26 Result SELECT * WHERE SELECT DISTINCT ?x ?y WHERE ORDER BY ?x DESC(?y) LIMIT 10 OFFSET 10

27 Distinct select distinct ?x ?z where { ?x :friend ?y ?y :friend ?z } Eliminate duplicate results (eliminate same variables with same values)

28 Order by select ?pers ?date:Jim :author :d2 where {:Jack :author :d1 ?pers :author ?doc:d2 :date ?doc :date ?date:d1 :date } order by ?date Result (1) pers = :Jim ; date = (2) pers = :Jack ; date =

29 Limit select * where { PATTERN } LIMIT 20 Return 20 results at most

30 Limit/Offset select * where { PATTERN } LIMIT 20 OFFSET results (at most), after the 10th result i.e. from 11th to 30th

31 Construct Return new RDF graph construct { ?girl :hasBrother ?boy } where { ?boy :hasSister ?girl }

32 Describe describe ?x where { ?x rdf:type :HotTopic ?x :date ?date filter (?date >= ‘ ’^^xsd:date) } Return a description of ?x The appropriate description of a resource is determined by the RDF store

33 Ask ask {:Olivier :teach :ensi} yes/no answer

34 Negation as failure Persons that are member of an organization and who have not created a document : SELECT * WHERE { ?x c:isMemberOf ?org. OPTIONAL { ?x c:hasCreated ?doc } FILTER (! bound(?doc)) }

35 Extension Function (user defined)‏ PREFIX fun: SELECT * WHERE { ?x c:age ?age. FILTER fun:prime(?age) }

36 XML Result Format...

37 XML Result Format

38 XML Result Format r2 Bob 30

39 SPARQL 1.1 Query Language W3C Project Expression Aggregates Property Path New statements Minus, Exists Subquery

40 Project Expression Return the result of an expression select * (ext:price(?doc) as ?price) where { ?doc rdf:type c:Document ?doc c:author ?a }

41 New filters coalesce(?x, ?y, 10): return first value that is not an error (such as unbound) if(?x>10, ?y, ?x+10) ?x in (“alpha”, ?beta, ‘gamma’)

42 New functions strlen, concat, substr, strstarts, strends, contains year, month, day, hours, minutes, seconds

43 Aggregates Compute a global result over the list of results: min, max, count sum, avg group_concat sample

44 Aggregates select(count(?doc) as ?count) where { ?x c:hasCreated ?doc }

45 Aggregates select ?x (count(?doc) as ?count) where { ?x c:hasCreated ?doc } group by ?x

46 Aggregates: distinct select ?x (count(distinct ?doc) as ?count) where { ?x foaf:knows ?y ?y c:hasCreated ?doc } group by ?x

47 Having Additional filter after aggregate select ?x (count(?doc) as ?count) where { ?x c:hasCreated ?doc } group by ?x having (count(?doc) >= 10)

48 Aggregates 1. min 2. max 3. sum 4. avg 5. count 6. group_concat 7. sample

49 Aggregates Return one result when there is no group by select (min(?price) as ?min) where { ?x ex:price ?price }

50 Aggregates Return one result for each « group by » key select ?class (min(?price) as ?min) where { ?x a ?class ; ex:price ?price } group by ?class

51 Aggregates Count the number of results select (count(*) as ?count) where { ?x ex:price ?price }

52 Aggregates Count the number of distinct results select (count(distinct *) as ?count) where { ?x ex:price ?price }

Property Path 53 Retrieve resources linked by a path in the graph ?x foaf:knows ?y

Property Path 54 Retrieve resources linked by a path in the graph ?x foaf:knows/foaf:knows ?y

Property Path 55 Retrieve resources linked by a path in the graph ?x foaf:knows/foaf:knows/foaf:knows ?y

Property Path 56 prefix foaf: select * where { ?x foaf:knows+ ?y ; foaf:name ‘Olivier’ }

Property Path foaf:knows OlivierFabien 57 prefix foaf: select * where { ?x foaf:knows+ ?y ; foaf:name ‘Olivier’ }

Property Path foaf:knows OlivierFabien foaf:knows Alain 58 prefix foaf: select * where { ?x foaf:knows+ ?y ; foaf:name ‘Olivier’ }

Property Path foaf:knows OlivierFabien foaf:knows Alain Oumy foaf:knows 59 prefix foaf: select * where { ?x foaf:knows+ ?y ; foaf:name ‘Olivier’ }

60 Property Path select ?val where { xxx rdf:rest*/rdf:first ?val } _:b1 first rest _:b2 first _:b3 first rest am stram gram

61 Property Path Expression Operators / : sequence | : alternative + : one or several * : zero or several ? : optional ^ : reverse ! : negation

62 Negation : Minus Remove from the member of org the resources whose name is ‘Olivier’ select * where { ?x c:memberOf ?org minus {?x c:name ‘Olivier’} }

63 MINUS may remove nothing select * where { ?x c:memberOf ?org minus {?y c:name ‘Olivier’} } Remove results that are compatible (same variables have same values) when there is at least one common variable

64 Negation : Not Exists ?x c:memberOf ?org. filter( not exists {?x c:author ?doc } )

65 Minus vs Exists Same results: ?x c:memberOf ?org. filter(! exists {?x c:author ?doc }) ?x c:memberOf ?org. minus {?x c:author ?doc }

66 Minus vs Exists Different results: ?x c:memberOf ?org. filter(! exists {?y c:author ?doc }) ?x c:memberOf ?org. minus {?y c:author ?doc }

67 Sub Query Find properties of the cheapest car select * where { {select (min(?price) as ?min) where { ?car ex:hasPrice ?price} } ?car ex:hasPrice ?min ?car ?p ?val }

68 Bindings select * where { ?x foaf:knows ?y } values ?x { ex:Robert ex:Jimmy ex:John }

69 Service select * where { ?x foaf:name ‘Olivier’ service { ?x ?p ?y }

70 SPARQL 1.1 Update Update language for RDF graphs CRUD: Create Read Update Delete

71 Insert Data PREFIX dc: INSERT DATA { dc:title "A new book" ; dc:creator "A.N.Other". }

Delete Data PREFIX dc: DELETE DATA { dc:title "A new book" ; dc:creator "A.N.Other". } 72

73 Delete PREFIX foaf: DELETE { ?person foaf:firstName 'Bill' } WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

74 Insert PREFIX foaf: INSERT { ?person foaf:firstName 'William' } WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

75 Delete Insert PREFIX foaf: DELETE { ?person foaf:firstName 'Bill' } INSERT { ?person foaf:firstName 'William' } WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

76 Insert Graph PREFIX foaf: INSERT { graph { ?person foaf:firstName 'William' } } WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

77 Using: like From PREFIX foaf: INSERT {?person foaf:firstName 'William' } USING WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

78 With PREFIX foaf: WITH INSERT {?person foaf:firstName 'William' } WHERE { ?person a foaf:Person. ?person foaf:firstName 'Bill' }

79 Update LOAD [ INTO GRAPH ] CLEAR [ SILENT ] (GRAPH | DEFAULT | NAMED | ALL ) DROP [ SILENT ] (GRAPH | DEFAULT | NAMED | ALL ) CREATE [ SILENT ] GRAPH