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.

Slides:



Advertisements
Similar presentations
Dr. Leo Obrst MITRE Information Semantics Information Discovery & Understanding Command & Control Center February 6, 2014February 6, 2014February 6, 2014.
Advertisements

CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
XML: Extensible Markup Language
Lukas Blunschi Claudio Jossen Donald Kossmann Magdalini Mori Kurt Stockinger.
Ontology Engineering Lab #8 October 21, Review - Trial Query Exercises  What are the bones of the foot? (not sure this can be done in a single.
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 2004 Digital Enterprise Research Institute. All rights reserved. SPARQL Query Language for RDF presented by Cristina Feier.
SPARQL RDF Query.
The Web of data with meaning... By Michael Griffiths.
SPARQL for Querying PML Data Jitin Arora. Overview SPARQL: Query Language for RDF Graphs W3C Recommendation since 15 January 2008 Outline: Basic Concepts.
CSCI 572 Project Presentation Mohsen Taheriyan Semantic Search on FOAF profiles.
RDF: Building Block for the Semantic Web Jim Ellenberger UCCS CS5260 Spring 2011.
Semantic Web Presented by: Edward Cheng Wayne Choi Tony Deng Peter Kuc-Pittet Anita Yong.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
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.
Metadata Standards and Applications 4. Metadata Syntaxes and Containers.
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.
Semantic Web Series 1 Mohammad M. R. Cowdhury UniK, Kjeller.
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:
LOD 123: Making the semantic web easier to use Tim Finin University of Maryland, Baltimore County Joint work with Lushan Han, Varish Mulwad, Anupam Joshi.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
Introduction to SPARQL. Acknowledgements This presentation is based on the W3C Candidate Recommendation “SPARQL Query Language for RDF” from
Entity Recognition via Querying DBpedia ElShaimaa Ali.
RDF Query language The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web.
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
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:
The LOM RDF binding – update Mikael Nilsson The Knowledge Management.
RQL: RDF Query language Jianguo Lu University of Windsor The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer”
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!
Tool for Ontology Paraphrasing, Querying and Visualization on the Semantic Web Project By Senthil Kumar K III MCA (SS)‏
Introduction to the Semantic Web and Linked Data Module 1 - Unit 2 The Semantic Web and Linked Data Concepts 1-1 Library of Congress BIBFRAME Pilot Training.
The RDF meta model Basic ideas of the RDF Resource instance descriptions in the RDF format Application-specific RDF schemas Limitations of XML compared.
The Semantic Web Matt Klubertanz. What is it? “The Semantic Web is an extension of the current web in which information is given well- defined meaning,
05/01/2016 SPARQL SPARQL Protocol and RDF Query Language S. Garlatti.
Chapter 3 Querying RDF stores with SPARQL
RDF and Relational Databases
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 8: SPARQL (1.1) Aidan Hogan
RDF & SPARQL Introduction Dongfang Xu Ph.D student, School of Information, University of Arizona Sept 10, 2015.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 7: SPARQL (1.0) Aidan Hogan
Ontology Technology applied to Catalogues Paul Kopp.
Chapter 04 Semantic Web Application Architecture 23 November 2015 A Team 오혜성, 조형헌, 권윤, 신동준, 이인용.
GoRelations: an Intuitive Query System for DBPedia Lushan Han and Tim Finin 15 November 2011
Semantic Web in Depth SPARQL Protocol and RDF Query Language Dr Nicholas Gibbins –
26/02/ WSMO – UDDI Semantics Review Taxonomies and Value Sets Discussion Paper Max Voskob – February 2004 UDDI Spec TC V4 Requirements.
OWL (Ontology Web Language and Applications) Maw-Sheng Horng Department of Mathematics and Information Education National Taipei University of Education.
Linked Data Web that can be processed by machines
CC La Web de Datos Primavera 2017 Lecture 7: SPARQL [i]
CC La Web de Datos Primavera 2016 Lecture 8: SPARQL (1.1)
CC La Web de Datos Primavera 2017 Lecture 8: SPARQL [ii]
SPARQL SPARQL Protocol and RDF Query Language
SPARQL: A query language for RDF
SPARQL + RDF Based on: Prof. Benny Kimelfled’s lecture notes
SISAI STATISTICAL INFORMATION SYSTEMS ARCHITECTURE AND INTEGRATION
Logics for Data and Knowledge Representation
CC La Web de Datos Primavera 2016 Lecture 7: SPARQL (1.0)
LOD reference architecture
CC La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1]
JSON for Linked Data: a standard for serializing RDF using JSON
CSE591: Data Mining by H. Liu
Logics for Data and Knowledge Representation
Presentation transcript:

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 and update triples in one or more triples stores It’s key to exploiting Linked Open Data

Three RDF use cases Markup web documents with semi-structured data for better understanding by search engines (Microdata) Use as a data interchange language that’s more flexible and has a richer semantic schema than XML or SQL Assemble and link large datasets and publish as as knowledge bases to support a domain (e.g., genomics) or in general (DBpedia)

Three RDF use cases Markup web documents with semi-structured data for better understanding by search engines (Microdata) Use as a data interchange language that’s more flexible and has a richer semantic schema than XML or SQL Assemble and link large datasets and publish as as knowledge bases to support a domain (e.g., genomics) or in general (DBpedia) – Such knowledge bases may be very large, e.g., Dbpedia has ~300M triples – Using such a large dataset requires a language to query and update it

Semantic web technologies allow machines to share data and knowledge using common web language and protocols. ~ 1997 Semantic Web Semantic Web beginning Use Semantic Web Technology to publish shared data & knowledge

2007 Semantic Web => Linked Open Data Use Semantic Web Technology to publish shared data & knowledge Data is inter- linked to support inte- gration and fusion of knowledge LOD beginning

2008 Semantic Web => Linked Open Data Use Semantic Web Technology to publish shared data & knowledge Data is inter- linked to support inte- gration and fusion of knowledge LOD growing

2009 Semantic Web => Linked Open Data Use Semantic Web Technology to publish shared data & knowledge Data is inter- linked to support inte- gration and fusion of knowledge … and growing

Linked Open Data 2010 LOD is the new Cyc: a common source of background knowledge Use Semantic Web Technology to publish shared data & knowledge Data is inter- linked to support inte- gration and fusion of knowledge …growing faster

Linked Open Data 2011: 31B facts in 295 datasets interlinked by 504M assertions on ckan.netckan.net LOD is the new Cyc: a common source of background knowledge Use Semantic Web Technology to publish shared data & knowledge Data is inter- linked to support inte- gration and fusion of knowledge

Linked Open Data (LOD) Linked data is just RDF data, typically just the instances (ABOX), not schema (TBOX) RDF data is a graph of triples – URI URI string dbr:Barack_Obama dbo:spouse “Michelle Obama” – URI URI URI dbr:Barack_Obama dbo:spouse dbpedia:Michelle_Obama Best linked data practice prefers the 2 nd pattern, using nodes rather than strings for “entities” Liked open data is just linked data freely acces- sible on the Web along with any required ontologies

Dbpedia: Wikipedia data in RDF

Available for download Broken up into files by information type Contains all text, links, infobox data, etc. Supported by several ontologies Updated ~ every 3 months About 300M triples!

Queryable You can query any of several RDF triple stores Or download the data, load into a store and query it locally

Browseable There are also RDF browsers These are driven by queries against a RDF triple store loaded with the DBpedia data

Why an RDF Query Language? Why not use an XML query language? 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 XPath queries, e.g. – //uni:lecturer/uni:title if uni:title element – if uni:title attribute – Both XML representations equivalent!

SPARQL A key to exploiting such large RDF data sets is the SPARQL query language Sparql Protocol And Rdf Query Language W3C began developing a spec for a query language in 2004 There were/are other RDF query languages, and extensions, e.g., RQL and Jena’s ARQRDF query languagesARQ SPARQL a W3C recommendation in 2008 SPARQL SPARQL 1.1 is a proposed recommendation with update, aggregation functions, federation & more SPARQL 1.1 Most triple stores support SPARQL 1.1

SPARQL Example PREFIX foaf: SELECT ?name ?age WHERE { ?person a foaf:Person. ?person foaf:name ?name. ?person foaf:age ?age } ORDER BY ?age DESC LIMIT 10

SPARQL Protocol, Endpoints, APIs SPARQL query language SPROT = SPARQL Protocol for RDF – Among other things specifies how results can be encoded as RDF, XML or JSON SPARQL endpoint – A service that accepts queries and returns results via HTTP – Either generic (fetching data as needed) or specific (querying an associated triple store) – May be a service for federated queries

SPARQL Basic Queries SPARQL is based on matching graph patterns The simplest graph pattern is the triple pattern - ?person foaf:name ?name - Like an RDF triple, but variables can be in any position - Variables begin with a question mark Combining triple patterns gives a graph pattern; an exact match to a graph is needed Like SQL, a set of results is returned with a result for each way the graph pattern can be instantiated

Turtle Like Syntax As in Turtle and N3, we can omit a common subject in a graph pattern. PREFIX foaf: SELECT ?name ?age WHERE { ?person a foaf:Person; foaf:name ?name; foaf:age ?age }

Optional Data The query fails unless the entire pattern matches We often want to collect some information that might not always be available Note difference with relational model PREFIX foaf: SELECT ?name ?age WHERE { ?person a foaf:Person; foaf:name ?name. OPTIONAL {?person foaf:age ?age} }

Example of a Generic Endpoint Use the sparql endpoint at – To query graph at – For foaf knows relations SELECT ?name ?p2 WHERE { ?person a foaf:Person; foaf:name ?name; foaf:knows ?p2. }

Example

Query results as HTML

Other result format options

Example of a dedicated Endpoint Use the sparql endpoint at – To query DBpedia To discover places associated with President Obama PREFIX dbp: PREFIX dbpo: SELECT distinct ?Property ?Place WHERE {dbp:Barack_Obama ?Property ?Place. ?Place rdf:type dbpo:Place.}

PREFIX dbp: PREFIX dbpo: SELECT distinct ?Property ?Place WHERE {dbp:Barack_Obama ?Property ?Place. ?Place rdf:type dbpo:Place.}

SELECT FROM The FROM clause lets us specify the target graph in the query SELECT * returns all PREFIX foaf: SELECT * FROM WHERE { ?P1 foaf:knows ?p2 }

A generic web client Try it: Source:

FILTER Find landlocked countries with a population >15 million PREFIX rdfs: PREFIX type: PREFIX prop: SELECT ?country_name ?population WHERE { ?country a type:LandlockedCountries ; rdfs:label ?country_name ; prop:populationEstimate ?population. FILTER (?population > ). }

FILTER Functions Logical: !, &&, || Math: +, -, *, / Comparison: =, !=, >, <,... SPARQL tests: isURI, isBlank, isLiteral, bound SPARQL accessors: str, lang, datatype Other: sameTerm, langMatches, regex Conditionals (SPARQL 1.1): IF, COALESCE Constructors (SPARQL 1.1): URI, BNODE, STRDT, STRLANG Strings (SPARQL 1.1): STRLEN, SUBSTR, UCASE, … More math (SPARQL 1.1): abs, round, ceil, floor, RAND Date/time (SPARQL 1.1): now, year, month, day, hours, … Hashing (SPARQL 1.1): MD5, SHA1, SHA224, SHA256, …

Union The UNION keyword forms a disjunction of two graph patterns Both subquery results are included PREFIX foaf: PREFIX vCard: SELECT ?name WHERE { { [ ] foaf:name ?name } UNION { [ ] vCard:FN ?name } }

Query forms Each form takes a WHERE block to restrict the query SELECT: Extract raw values from a SPARQL endpoint, the results are returned in a table format CONSTRUCT: Extract information from the SPARQL endpoint and transform the results into valid RDF ASK: Returns a simple True/False result for a query on a SPARQL endpoint DESCRIBE Extract an RDF graph from the SPARQL endpoint, the contents of which is left to the endpoint to decide based on what the maintainer deems as useful information

SPARQL 1.1 SPARQL 1.1 includes Updated 1.1 versions of SPARQL Query and SPARQL Protocol SPARQL 1.1 Update SPARQL 1.1 Graph Store HTTP Protocol SPARQL 1.1 Service Descriptions SPARQL 1.1 Entailments SPARQL 1.1 Basic Federated Query

Summary An important usecase for RDF is exploiting large collections of semi-structured data, e.g., the linked open data cloud We need a good query language for this SPARQL is the SQL of RDF SPARQL is a language to query and update triples in one or more triples stores It’s key to exploiting Linked Open Data