SPARQL- A QUERY LANGUAGE FOR RDF( S ) Fred Freitas - CIn/UFPE - Brazil.

Slides:



Advertisements
Similar presentations
SPARQL Query Language for RDF
Advertisements

1Patrick Stickler © 2004 Nokia Nokia Semantic Web Server Patrick Stickler Forum Nokia Web Services Nokia Technology Platforms
1 SPARQL: A query language for RDF Matthew Yau
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C4.
Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
The Semantic Web – WEEK 4: RDF
Introduction to RDF Based on tutorial at
1 © Copyright 2010 Dieter Fensel, Federico Facca and Ioan Toma Semantic Web Storage and Querying.
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.
Jena Sparql 4/11/2017.
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.
Speaker: Daniel Vila-Suero The SPARQL Query Language Raúl García-Castro, Óscar Corcho, Daniel Vila-Suero Ontology Engineering Group Universidad.
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.
Semantic Web Andrejs Lesovskis. Publishing on the Web Making information available without knowing the eventual use; reuse, collaboration; reproduction.
VLDB 2005 An Efficient SQL-based RDF Querying Scheme Eugene Inseok Chong Souripriya Das George Eadon Jagannathan Srinivasan New England Development Center.
Semantic Web Bootcamp Dominic DiFranzo PhD Student/Research Assistant Rensselaer Polytechnic Institute Tetherless World Constellation.
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.
1 Ontology Query and Reasoning Payam Barnaghi Institute for Communication Systems (ICS) Faculty of Engineering and Physical Sciences University of Surrey.
RDF (Resource Description Framework) Why?. XML XML is a metalanguage that allows users to define markup XML separates content and structure from formatting.
SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link:
Introduction to SPARQL. Acknowledgements This presentation is based on the W3C Candidate Recommendation “SPARQL Query Language for RDF” from
RDF Query language The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web.
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.
Database Support for Semantic Web Masoud Taghinezhad Omran Sharif University of Technology Computer Engineering Department Fall.
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall Querying on the Web: XQuery, RDQL, SparQL Semantic Web.
SPARQL W3C Simple Protocol And RDF Query Language
Ontology Query. What is an Ontology Ontologies resemble faceted taxonomies but use richer semantic relationships among terms and attributes, as well as.
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:
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.
RQL: RDF Query language Jianguo Lu University of Windsor The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer”
Semantic Web Exam 1 Review.
Semantically Processing The Semantic Web Presented by: Kunal Patel Dr. Gopal Gupta UNIVERSITY OF TEXAS AT DALLAS.
EEL 5937 Ontologies EEL 5937 Multi Agent Systems Lecture 5, Jan 23 th, 2003 Lotzi Bölöni.
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!
Practical RDF Chapter 10. Querying RDF: RDF as Data Shelley Powers, O’Reilly SNU IDB Lab. Hyewon Lim.
Understanding RDF. 2/30 What is RDF? Resource Description Framework is an XML-based language to describe resources. A common understanding of a resource.
User Profiling using Semantic Web Group members: Ashwin Somaiah Asha Stephen Charlie Sudharshan Reddy.
Practical RDF Ch.10 Querying RDF: RDF as Data Taewhi Lee SNU OOPSLA Lab. Shelley Powers, O’Reilly August 27, 2004.
Dr. Bhavani Thuraisingham September 24, 2008 Building Trustworthy Semantic Webs Lecture #9: RDF and RDF Security.
Ontology based e-Real Estate Agency Information System By Moein Mehrolhasani Bijan Zamanian cmpe 588.
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:
Alexandra Cristea 1.  pronounced "sparkle“  recursive acronym for: ◦ SPARQL Protocol and RDF Query Language  a semantic query language  a query language.
Of 38 lecture 6: rdf – axiomatic semantics and query.
RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015.
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.
Lecture 8: RDF& SPARQL Dr. Taysir Hassan A. Soliman December 13, 2015 INF411 Information Engineering Information Systems Dept. Faculty of Computers & Information.
Semantic Web in Depth SPARQL Protocol and RDF Query Language Dr Nicholas Gibbins –
Vincenzo Maltese, Fausto Giunchiglia University of Trento
SPARQL.
Introduction to SPARQL
SPARQL SPARQL Protocol and RDF Query Language
SPARQL: A query language for RDF
Jena Sparql (for Mac) 9/22/2018.
Logics for Data and Knowledge Representation
Lecture #6: RDF and RDF Security Dr. Bhavani Thuraisingham
Logics for Data and Knowledge Representation
Presentation transcript:

SPARQL- A QUERY LANGUAGE FOR RDF( S ) Fred Freitas - CIn/UFPE - Brazil

Q UERY L ANGUAGES : SQL (SQL Q UERY L ANGUAGE ) [O RACLE 2006] A language for querying collections of tuples: SELECT SALARY, HIRE_DATE FROM EMPS WHERE EMP_ID = EMP_IDNAMEHIRE_DATESALARY 13954Joe Mary ………… 04182Bob

Q UERY L ANGUAGES : XQ UERY (XML Q UERY ) [O RACLE 2006] A language for querying trees of XDM nodes: for $e in document(my_employees.xml) where = return $emp/emp/salary

Chapter 3A Semantic Web Primer 4 W HY AN RDF Q UERY L ANGUAGE ? D IFFERENT XML R EPRESENTATIONS XML at a lower level of abstraction than RDF There are various ways of syntactically representing an RDF statement in XML Thus we would require several XQuery queries, e.g. //uni:lecturer/uni:title if uni:title element if uni:title attribute Both XML representations equivalent!

T WO BASIC FAMILIES OF SQL- LIKE LANGAGES FOR RDF(S) RDQL Implementations: Jena, Sesame, RDFStore,... RQL Implementations: RQL, SPARQL,...

6 I NTRODUCTION TO RDQL RDF Data Query Language JDBC/ODBC friendly Simple: SELECT some information FROM somewhere WHERE this match AND these constraints USING these vocabularies

7 E XAMPLE

8 q1 contains a query: SELECT ?x WHERE (?x,, "John Smith") For executing q1with a model m1.rdf: java jena.rdfquery --data m1.rdf --query q1 The outcome is: x =============================

9 E XAMPLE Return all the resources that have property FN and the associated values: SELECT ?x, ?fname WHERE (?x,, ?fname) The outcome is: x | fname ================================================ | "John Smith" | "Sarah Jones" | "Matt Jones"

10 E XAMPLE Return the first name of Jones: SELECT ?givenName WHERE (?y,, "Jones"), (?y,, ?givenName) The outcome is: givenName ========= "Matthew" "Sarah"

11 URI P REFIXES : USING RDQL has a syntactic convenience that allows prefix strings to be defined in the USING clause : SELECT ?x WHERE (?x, vCard:FN, "John Smith") USING vCard FOR SELECT ?givenName WHERE (?y, vCard:Family, "Smith"), (?y, vCard:Given, ?givenName) USING vCard FOR

12 F ILTERS RDQL has a syntactic convenience that allows prefix strings to be defined in the USING clause : SELECT ?resource WHERE (?resource, info:age, ?age) AND ?age >= 24 USING info FOR

13 L IMITATIONS Does not take into account semantics of RDF(S) For example: ex:human rdfs:subClassOf ex:animal ex:student rdfs:subClassOf ex:human ex:john rdf:type ex:student Query: “ To which class does the resource John belong?” Expected answer: ex:student, ex:human, ex:animal However, the query: SELECT ?x WHERE (, rdf:type, ?x) USING rdf FOR Yields only: Solution: Inference Engines

SPARQL SPARQL is a recursive acronym standing for SPARQL Protocol and RDF Query Language It provides facilities to [Staab 2006]: extract information in the form of URIs, blank nodes, plain and typed literals. extract RDF subgraphs. construct new RDF graphs based on information in the queried graphs

G RAPH P ATTERNS Basic Graph Pattern – set of Triple Patterns Group Pattern - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Pattern – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

B ASIC G RAPH P ATTERN Set of Triple Patterns Triple Pattern – similar to an RDF Triple (subject, predicate, object), but any component can be a query variable; literal subjects are allowed Matching a triple pattern to a graph: bindings between variables and RDF Terms Matching of Basic Graph Patterns A Pattern Solution of Graph Pattern GP on graph G is any substitution S such that S(GP) is a subgraph of G. xv rdf:typerdf:Property rdf:type rdf:type rdf:Property SELECT ?x ?v WHERE { ?x ?x ?v } ?book dc:title ?title

B ASIC G RAPH P ATTERN - M ULTIPLE M ATCHES PREFIX foaf: SELECT ?name ?mbox WHERE { ?x foaf:name ?name. ?x foaf:mbox ?mbox foaf:. _:a foaf:name "Johnny Lee Outlaw". _:a foaf:mbox. _:b foaf:name "Peter Goodguy". _:b foaf:mbox. namembox "Johnny Lee Outlaw" "Peter Goodguy" Group Graph Pattern (set of graph patterns) also! Data Query Query Result

B ASIC G RAPH P ATTERN - B LANK N ODES PREFIX foaf: SELECT ?x ?name WHERE { ?x foaf:name ?name foaf:. _:a foaf:name "Alice". _:b foaf:name "Bob". xname _:c“Alice“ _:d“Bob” Data Query Query Result

G RAPH P ATTERNS Basic Graph Pattern – set of Triple Patterns Group Pattern - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Pattern – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

G ROUP P ATTERN PREFIX foaf: SELECT ?name ?mbox WHERE { ?x foaf:name ?name. ?x foaf:mbox ?mbox } PREFIX foaf: SELECT ?name ?mbox WHERE { {?x foaf:name ?name; foaf:mbox ?mbox } }

G RAPH P ATTERNS Basic Graph Pattern – set of Triple Patterns Group Pattern - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Pattern – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

V ALUE C ONSTRAINTS PREFIX dc: PREFIX ns: SELECT ?title ?price WHERE { ?x ns:price ?price. FILTER ?price < 30. ?x dc:title ?title. ns:. :book1 dc:title "SPARQL Tutorial". :book1 ns:price 42. :book2 dc:title "The Semantic Web". :book2 ns:price 23. titleprice "The Semantic Web"23 Data Query Query Result

23 R EGULAR EXPRESSIONS CAN BE USED PREFIX dc: PREFIX ldap: PREFIX foaf: SELECT ?name ?name2 { ?doc dc:title ?title. FILTER regex(?title, “SPARQL”). ?doc dc:creator ?reseacher. ?researcher ldap: ? . ?researcher ldap:name ?name } “Find the name and addresses of authors of a paper about SPARQL”

G RAPH P ATTERNS Basic Graph Pattern – set of Triple Patterns Group Pattern - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Pattern – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

O PTIONAL GRAPH PATTERNS PREFIX dc: PREFIX ns: SELECT ?title ?price WHERE { ?x dc:title ?title. OPTIONAL { ?x ns:price ?price. FILTER ?price < 30 ns:. :book1 dc:title "SPARQL Tutorial". :book1 ns:price 42. :book2 dc:title "The Semantic Web". :book2 ns:price 23. titleprice “SPARQL Tutorial“ "The Semantic Web"23 Data Query Query Result

M ULTIPLE O PTIONAL B LOCKS PREFIX foaf: SELECT ?name ?mbox ?hpage WHERE { ?x foaf:name ?name. OPTIONAL { ?x foaf:mbox ?mbox }. OPTIONAL { ?x foaf:homepage ?hpage } rdfs:. _:a foaf:name "Alice". _:a foaf:homepage. _:b foaf:name "Bob". _:b foaf:mbox. Data Query Query Result nameMboxhpage “Alice“ “Bob“

G RAPH P ATTERNS Basic Graph Patterns – set of Triple Patterns Group Patterns - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Patterns – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

A LTERNATIVE G RAPH P ATTERNS PREFIX dc10: PREFIX dc11: SELECT ?x ?y WHERE { { ?book dc10:title ?x } UNION { ?book dc11:title ?y } dc11:. _:a dc10:title "SPARQL Query Language Tutorial". _:b dc11:title "SPARQL Protocol Tutorial". _:c dc10:title "SPARQL". _:c dc11:title "SPARQL (updated)". Data Query Query Result xy "SPARQL (updated)" "SPARQL Protocol Tutorial" "SPARQL" "SPARQL Query Language Tutorial"

G RAPH P ATTERNS Basic Graph Pattern – set of Triple Patterns Group Pattern - a set of graph patterns must all match Value Constraints - restrict RDF terms in a solution Optional Graph Patterns.- additional patterns may extend the solution Alternative Graph Pattern – two or more possible patterns are tried Patterns on Named Graphs - patterns are matched against named graphs

RDF D ATASET RDF data stores may hold multiple RDF graphs: record information about each graph queries that involve information from more than one graph RDF Dataset in SPARQL terminology the background graph, which does not have a name, and zero or more named graphs, identified by URI reference the relationship between named and background graphs: (i) to have information in the background graph that includes provenance information about the named graphs (the application is not directly trusting the information in the named graphs ) (ii) to include the information in the named graphs in the background graph as well.

RDF D ATASET - T HE R ELATIONSHIP BETWEEN N AMED AND B ACKGROUND G RAPHS (I) # Background dc:. dc:publisher "Bob". dc:publisher "Alice". # Graph: foaf:. _:a foaf:name "Bob". _:a foaf:mbox. # Graph: foaf:. _:a foaf:name "Alice". _:a foaf:mbox.

RDF D ATASET - T HE R ELATIONSHIP BETWEEN N AMED AND B ACKGROUND G RAPHS (II) # Background foaf:. _:x foaf:name "Bob". _:x foaf:mbox. _:y foaf:name "Alice". _:y foaf:mbox. # Graph: foaf:. _:a foaf:name "Bob". _:a foaf:mbox. # Graph: foaf:. _:a foaf:name "Alice". _:a foaf:mbox.

Q UERYING THE D ATASET # Graph: rdfs:. _:a foaf:name "Alice". _:a foaf:mbox. _:a foaf:knows _:b. _:b rdfs:seeAlso. rdf:type foaf:PersonalProfileDocument. _:b foaf:name "Bob". _:b foaf:mbox. _:b foaf:age 32. # Graph: rdfs:. _:1 foaf:mbox. _:1 rdfs:seeAlso. _:1 foaf:age 35. rdf:type foaf:PersonalProfileDocument.

Q UERYING THE D ATASET - A CCESSING G RAPH L ABELS PREFIX foaf: SELECT ?src ?bobAge WHERE { GRAPH ?src { ?x foaf:mbox. ?x foaf:age ?bobAge } } srcbobAge 32 35

Q UERYING THE D ATASET - R ESTRICTING BY G RAPH L ABEL PREFIX foaf: PREFIX data: SELECT ?age WHERE { GRAPH data:bobFoaf { ?x foaf:mbox. ?x foaf:age ?age } } age 35

Q UERYING THE D ATASET - R ESTRICTING VIA Q UERY P ATTERN PREFIX data: PREFIX foaf: PREFIX rdf: PREFIX rdfs: SELECT ?mbox ?age ?ppd WHERE { GRAPH data:aliceFoaf { ?alice foaf:mbox ; foaf:knows ?whom. ?whom foaf:mbox ?mbox ; rdfs:seeAlso ?ppd. ?ppd a foaf:PersonalProfileDocument. }. GRAPH ?ppd { ?w foaf:mbox ?mbox ; foaf:age ?age } } mboxageppd 35

C ONSTRUCTING AN O UTPUT G RAPH foaf:. _:a foaf:givenname "Alice". _:a foaf:family_name "Hacker". _:b foaf:firstname "Bob". _:b foaf:surname "Hacker". Query: PREFIX foaf: PREFIX vcard: CONSTRUCT { ?x vcard:N _:v. _:v vcard:givenName ?gname. _:v vcard:familyName ?fname } WHERE { { ?x foaf:firstname ?gname } UNION { ?x foaf:givenname ?gname }. { ?x foaf:surname ?fname } UNION { ?x foaf:family_name ?fname }. } vcard:. _:v1 vcard:N _:x. _:x vcard:givenName "Alice". _:x vcard:familyName "Hacker". _:v2 vcard:N _:z. _:z vcard:givenName "Bob". _:z vcard:familyName "Hacker".

ASK – A B OOLEAN rdfs:. _:a foaf:name "Alice". _:a foaf:homepage. _:b foaf:name "Bob". _:b foaf:mbox. PREFIX foaf: ASK { ?x foaf:name "Alice" } TRUE.

C ONCLUSIONS Several query languages for RDF/RDF(S) Some (not exclusive) SPARQL advantages Inferencing Implicit and explicit joins Once the schemas are defined elsewhere in RDF/RDF(S) too, they can also be queried upon! Many facilities: regex, datatypes, functions,... Queries built similarly to SQL... But also over graphs (in opposition to flat relational DBs).

40 A NY Q UESTIONS ?