Alexandra Cristea & Matthew Yau 1.

Slides:



Advertisements
Similar presentations
SPARQL Query Language for RDF
Advertisements

Knowledge Integration with SWRL Martin OConnor Stanford Center for Biomedical Informatics Research, Stanford University.
A Gentle Introduction to DDI - What's in it for me? Jim Jacobs University of California, San Diego Wendy Thomas University of Minnesota.
The Integration of Biological Data Using Semantic Web Technologies Susie Stephens Principal Product Manager, Life Sciences Oracle
© 2006 IBM Corporation Integrating Life Sciences Data on the Web using SPARQL Lee Feigenbaum May, 2006.
Searching and Ranking Ontologies on the Semantic Web Edward Thomas (Aberdeen) Harith Alani (Southampton) Derek Sleeman (Aberdeen) Christopher Brewster.
1 SPARQL: A query language for RDF Matthew Yau
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C4.
Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: C3.
Dr. Alexandra I. Cristea CS 411: Dynamic Web-Based Systems.
Semantic Descriptions for RESTful Services SA-REST by Knoesis Service Research Lab Tomas Vitvar WSMO Phone Conference January 09,
PROFFESSIONAL FOOTBALL CLUB ADMINISTRATION STRUCTURE by SEMANTIC WEB TECHNOLOGIES Polat ÇAKIROĞLU
OSLC Resource Shape: A Linked Data Constraint Language Arthur Ryman & Achille Fokoue, IBM W3C RDF Validation Workshop, Cambridge,
1 ARIN – KR Practical 1, Part 2 RDF Some of these slides are based on tutorial by Ivan Herman (W3C) reproduced here with kind permission. All changes and.
SPARQL Dimitar Kazakov, with references to material by Noureddin Sadawi ARIN, 2014.
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
© 2006 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Use Case: Populating Business Objects.
XML Craig Stewart Dr. Alexandra I. Cristea
Joshua Scotton OWL-QL.
1 An inference engine for the semantic web Naudts Guido Student at the Open University Netherlands.
PSSA Preparation.
Steffen Staab 1WeST Web Science & Technologies University of Koblenz ▪ Landau, Germany Structured Data on the Web Introduction to.
Web Data Management XQuery 1. In this lecture Summary of XQuery FLWOR expressions – For, Let, Where, Order by, Return FOR and LET expressions Collections.
Language (Formalisms) For Ontology Building Neda Alipanah 22 October 2012.
Internet Technologies 1 Master of Information System Management Internet Technologies Lecture 7: SPARQL.
The Semantic Web – WEEK 4: RDF
Introduction to RDF Based on tutorial at
Logics for Data and Knowledge Representation Projects and thesis introduction.
1 RDF Tutorial. C. Abela RDF Tutorial2 What is RDF? RDF stands for Resource Description Framework It is used for describing resources on the web Makes.
27 January Semantically Coordinated E-Market Semantic Web Term Project Prepared by Melike Şah 27 January 2005.
RDF – RESOURCE DESCRIPTION FRAMEWORK Antonio Bucchiarone FBK-IRST Trento, Italy 20 Novembre 2009.
Training Module 1.3 Introduction to RDF & SPARQL.
SPARQL : Simple Protocol and RDF Query Language 第一版整理人 : 簡學群 Date : 2014 / 12.
Using JavaScript in Linked Data Applications Oshani Seneviratne Oct 12, 2010.
ESDSWG2011 – Semantic Web session Semantic Web Sub-group Session ESDSWG 2011 Meeting – Semantic Web sub-group session Wednesday, November 2, 2011 Norfolk,
RDF Tutorial.
CSCE Ontology Development Lecture 03 Semantic Web CSCE 510 April 29, 2013 Figure from Model Driven Architecture and Ontology Development.
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.
CSCI 572 Project Presentation Mohsen Taheriyan Semantic Search on FOAF profiles.
Semantic Web Andrejs Lesovskis. Publishing on the Web Making information available without knowing the eventual use; reuse, collaboration; reproduction.
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.
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.
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.
SPARQL W3C Simple Protocol And RDF Query Language
Semantic Web Programming in Python an Introduction Biju B Jaganath G.
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!
05/01/2016 SPARQL SPARQL Protocol and RDF Query Language S. Garlatti.
Alexandra Cristea 1.  pronounced "sparkle“  recursive acronym for: ◦ SPARQL Protocol and RDF Query Language  a semantic query language  a query language.
RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015.
Semantic Web for the Working Ontologist Dean Allemang Jim Hendler SNU IDB laboratory Last modified,
Dr. Alexandra I. Cristea CS 414: Semantic Web.
Semantic Web for the Working Ontologist Dean Allemang Jim Hendler SNU IDB laboratory.
Chapter 04 Semantic Web Application Architecture 23 November 2015 A Team 오혜성, 조형헌, 권윤, 신동준, 이인용.
Dr. Alexandra I. Cristea SPARQL Exerciess.
1 RDF Storage and Retrieval Systems Jan Pettersen Nytun, UiA.
Vincenzo Maltese, Fausto Giunchiglia University of Trento
SPARQL.
SPARQL SPARQL Protocol and RDF Query Language
SPARQL: A query language for RDF
Jan Pettersen Nytun, UiA
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
Presentation transcript:

Alexandra Cristea & Matthew Yau 1

 a query language for RDF(S)  W3C Recommendation 15 th January 2008 ◦ provides a standard format for writing queries that target RDF data ◦ and a set of standard rules for processing queries and returning the results   Read also: as guided on course website! 2

3 Subject Predicate author Object Jan Egil Refsnes SPARQL searches for all sub-graphs that match the graph described by the triples in the query. ?subject ?predicate ?object

SELECT ?student WHERE { ?student b:studies bmod:CS328 } ~ SQL 4

b:studies bmod:CS328 PREFIX b: PREFIX bmod: <  The PREFIX keyword is SPARQL ’ s version of an xmlns:namespace declaration and works in basically the same way. 5

 Different syntax from XML  Variables: begin with ? or $  triples patterns enclosed within braces {}  Result: variables after SELECT (~SQL) 6

PREFIX b: PREFIX bmod: PREFIX foaf: SELECT ?name WHERE { ?student b:studies bmod:CS328. ?student foaf:name ?name } 7

 FOAF (Friend Of A Friend)  experimental project using RDF, defining a standardised vocabulary.  Goal: make personal homepages machine- readable & understandable, create an internet- wide connected database of people. Defined at: 8

 Idea: most personal homepages contain similar info. ◦ E.g, person’s name, living place, work place, details on work of the moment, links to friends. ◦ define RDF predicates to represent them. ◦ So: Pages: understood/ manipulated by computers.  So a db can be queried for: ◦ “ what projects are my friends working on? ”, ◦ “ do any of my friends know the director of BigCorp? ” etc.. 9

Matthew Yau <foaf:mbox rdf:resource=" mailto: "/> 10

<rdf:RDF xmlns:rdf=" xmlns:rdfs=" xmlns:foaf=" Leigh Dodds Leigh Dodds 71b88e951 Dan Brickley fb0 11

PREFIX b: PREFIX bmod: PREFIX foaf: SELECT ?module ?name WHERE { ?student b:studies ?module. ?student foaf:name ?name } 12

PREFIX b: PREFIX bmod: terial/ PREFIX foaf: < SELECT ?module ?name WHERE { ?student b:studies ?module ; foaf:name ?name } 13

SELECT ?module ?name WHERE { ?student b:studies ?module. ?student b:studies bmod:CS328 ; foaf:name ?name } is identical to: SELECT ?module ?name WHERE { ?student b:studies ?module, bmod:CS328 ; foaf:name ?name } 14

SELECT ?student ? WHERE { ?student b:studies mod:CS328. ?student foaf:mbox ? }  PB: if a student does not have an address registered, with a foaf:mbox predicate, then the query will not match !! 15

SELECT ?student ? WHERE { ?student b:studies mod:CS328. OPTIONAL { ?student foaf:mbox ? } }  OPTIONAL: match it if it can, but otherwise not reject the overall pattern. 16

SELECT ?module ?name ?phone WHERE { ?student b:studies ?module. ?student foaf:name ?name. OPTIONAL { ?student b:contactpermission true. ?student b:phone ?phone } SELECT ?module ?name ?age WHERE { ?student b:studies ?module. ?student foaf:name ?name. OPTIONAL { ?student b:age ?age. FILTER (?age > 25) } } 17

SELECT ?student ? ?home WHERE { ?student b:studies mod:CS328. OPTIONAL { ?student foaf:mbox ? . ?student foaf:homepage ?home } } SELECT ?student ? ?home WHERE { ?student b:studies mod:CS328. OPTIONAL { ?student foaf:mbox ? }. OPTIONAL { ?student foaf:homepage ?home } } 18

SELECT ?student WHERE { ?student foaf:mbox ? . { ?student b:studies mod:CS328 } UNION { ?student b:studies mod:CS909 } }  When patterns are combined using the UNION keyword, the resulting combined pattern will match if any of the subpatterns is matched. 19

 All the previous queries : single RDF graphs.  Often: multiple RDF graphs.  RDF graphs: identified by URI. ◦ Note: URI that represents the graph does not have to be the actual URI of the graph file ◦ although the program processing the query will need to somehow relate the URI to an actual RDF graph stored somewhere. 20

SELECT ?student ? ?home FROM WHERE { ?student b:studies mod:CS909. OPTIONAL { ?student foaf:mbox ? . ?student foaf:homepage ?home } } By using several FROM declarations, you can combine several graphs in the dataset: SELECT ?student ? ?home FROM WHERE { ?student b:studies mod:CS909. OPTIONAL { ?student foaf:mbox ? . ?student foaf:homepage ?home } } 21

 one (optional) default graph  + any number of named graphs.  FROM specifies default graph. ◦ Many FROM keywords, the graphs are merged into the default graph.  Additionally: named graphs, w FROM NAMED. ◦ However, to match patterns you must use GRAPH keyword to state which graph ! 22

SELECT ?student ? ?home FROM NAMED FROM NAMED WHERE { GRAPH { ?student b:studies mod:CS909 }. GRAPH { OPTIONAL { ?student foaf:mbox ? . ?student foaf:homepage ?home } } 23

PREFIX brdf: SELECT ?student ? ?home FROM NAMED FROM NAMED WHERE { GRAPH brdf:student { ?student b:studies mod:CS909 }. GRAPH brdf:foaf{ OPTIONAL { ?student foaf:mbox ? . ?student foaf:homepage ?home } } 24

PREFIX brdf: SELECT ?student ? ?home FROM FROM NAMED WHERE { ?student b:studies mod:CS909. GRAPH brdf:foaf{ OPTIONAL { ?studentfoaf:mbox? . ?studentfoaf:homepage ?home } } 25

 the GRAPH can also be a variable. ◦ to query which graph in the dataset holds a particular relationship, ◦ or which graph to search based on data in another graph.  not mandatory to declare all graphs ◦ even if specified, the dataset can be overridden on a per-query basis. 26

PREFIX brdf: SELECT ?student ?graph WHERE { ?student b:studies mod:CS909. GRAPH ?graph { ?student foaf:mbox ? }  output var graph holds graph URL (matching student to address).  Presumption: query processor has knowledge of a finite set of graphs + their locations 27

PREFIX brdf: SELECT ?student ? WHERE { ?student b:studies mod:CS909. ?student rdfs:seeAlso ?graph. GRAPH ?graph { ?student foaf:mbox ? }  Note: if student doesn’t have a rdfs:seeAlso property which points to a graph holding their address, they will not appear in the result at all. 28

SELECT ?name ?module WHERE { ?student b:studies ?module. ?student foaf:name ?name. } ORDER BY ?name SELECT ?name ?age WHERE { ?student b:age ?age. ?student foaf:name ?name. } ORDER BY DESC (?age) ASC (?name) 29

SELECT ?name ?module WHERE { ?student b:studies ?module. ?student foaf:name ?name. } LIMIT 20 30

SELECT ?name ?module WHERE { ?student b:studies ?module. ?student foaf:name ?name. } ORDER BY ?name OFFSET 10 LIMIT 20 31

 Is any student studying any module? ASK { ?student b:studies ?module }  Is any student studying CS909? ASK { ?student b:studies bmod:CS909 }  Is student studying CS909? ASK { bstu: b:studies bmod:CS909 }  Is anyone whom knows, studying CS909? ASK {bstu: foaf:knows ?x. ?x b:studies bmod: CS909 }  Is any student aged over 30 studying CS909? ASK { ?student b:studies bmod:CS909. ?student b:age ?age. FILTER { ?age > 30 } } 32

SELECT ?student WHERE { ?student b:studies ?module } versus: SELECT DISTINCT ?student WHERE { ?student b:studies ?module } 33

CONSTRUCT { ?student b:studyFriend ?friend } WHERE { ?student b:studies ?module. ?student foaf:knows ?friend. ?friend b:studies ?module } }  If there is more than one search result, the triples from each result are combined. 34

 SPARQL language is used for querying RDF.  SPARQL is not based on XML, but on SQL- like syntax.  Building blocks of SPARQL queries are graph patterns that include variables. The result of the query will be the values the vars must take to match the RDF graph.  A SPARQL query can return results in several different ways, as determined by the query.  SPARQL queries can also be used for OWL querying. 35

 [1] Dean Allemang & Jim Hendler Semantic Web for the working ontologist. Morgan Kaufmann publishers. ISBN  [2] Eric Prud'hommeaux ; & Andy Seaborne SPARQL Query Language for RDF, [Online]

 Download Jena from  Prot é g é

38