CC La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1]

Slides:



Advertisements
Similar presentations
XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
Advertisements

4 Oracle Data Integrator First Project – Simple Transformations: One source, one target 3-1.
Characteristic Functions. Want: YearCodeQ1AmtQ2AmtQ3AmtQ4Amt 2001e (from fin_data table in Sybase Sample Database) Have: Yearquartercodeamount.
Semantic Web Introduction
1 Query-by-Example (QBE). 2 v A “GUI” for expressing queries. –Based on the Domain Relational Calulus (DRC)! –Actually invented before GUIs. –Very convenient.
Database Management Systems 3ed, Online chapter, R. Ramakrishnan and J. Gehrke1 Query-by-Example (QBE) Online Chapter Example is the school of mankind,
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
Structured Query Language – Continued Rose-Hulman Institute of Technology Curt Clifton.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
FALL 2004CENG 351 File Structures and Data Management1 SQL: Structured Query Language Chapter 5.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
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.
SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link:
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.
Fundamentals, Design, and Implementation, 9/e CPE 481 Database Processing Chapter 6 Structured Query Language (SQL) Instructor:Suthep Madarasmi, Ph.D.
SPARQL W3C Simple Protocol And RDF Query Language
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.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
Chapter 4: SQL Complex Queries Complex Queries Views Views Modification of the Database Modification of the Database Joined Relations Joined Relations.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Semantic Publishing Benchmark Task Force Fourth TUC Meeting, Amsterdam, 03 April 2014.
05/01/2016 SPARQL SPARQL Protocol and RDF Query Language S. Garlatti.
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 10: Conclusion Aidan Hogan
Management of Semantic Instances in resources using SPARQL update operation with HTTP verbs Group Name: MAS 19 Source: Minwoo Ryu, jaeho Kim, Sungchan.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 7: SPARQL (1.0) Aidan Hogan
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.
Tool for Ontology Paraphrasing, Querying and Visualization on the Semantic Web Project By Senthil Kumar K III MCA (SS)‏
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 –
1 CS122A: Introduction to Data Management Lecture 9 SQL II: Nested Queries, Aggregation, Grouping Instructor: Chen Li.
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]
MySQL Subquery Source: Dev.MySql.com
CC La Web de Datos Primavera 2016 Lecture 8: SPARQL (1.1)
CC La Web de Datos Primavera 2017 Lecture 8: SPARQL [ii]
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Instructor: Craig Duckett Lecture 09: Tuesday, April 25th, 2017
PL/SQL LANGUAGE MULITPLE CHOICE QUESTION SET-1
Subqueries Schedule: Timing Topic 25 minutes Lecture
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 5: Aggregate Functions and Grouping of Data
SPARQL + RDF Based on: Prof. Benny Kimelfled’s lecture notes
CS 405G: Introduction to Database Systems
Logics for Data and Knowledge Representation
CC La Web de Datos Primavera 2016 Lecture 7: SPARQL (1.0)
Triple Stores.
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
CC La Web de Datos Primavera 2016 Lecture 2: RDF Model & Syntax
Chapter 2 Views.
CC La Web de Datos Primavera Lecture 5: Web Ontology Language (II)
Access: SQL Participation Project
SQL: Structured Query Language
Chapter 2 Views.
Structured Query Language – The Fundamentals
M1G Introduction to Database Development
Contents Preface I Introduction Lesson Objectives I-2
Chapter 8 Advanced SQL.
Boolean Expressions to Make Comparisons
Subqueries Schedule: Timing Topic 25 minutes Lecture
Graph Data on the Web: extend the pivot, don’t reinvent the wheel
Database Systems: Design, Implementation, and Management Tenth Edition
IST 318 Database Administration
Subqueries Schedule: Timing Topic 25 minutes Lecture
Subqueries Schedule: Timing Topic 25 minutes Lecture
Presentation transcript:

CC7220-1 La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1] Aidan Hogan aidhog@gmail.com

Previously …

First SPARQL (1.0) Then SPARQL 1.1

Covered SPARQL 1.0 http://www.w3.org/TR/rdf-sparql-query/

Today: SPARQL 1.1

A Web standard http://www.w3.org/TR/sparql11-query/

What’s new in SPARQL 1.1? New query features An update language Support for RDFS/OWL entailment New output formats

Query feature: Negation

SPARQL 1.0: Negation possible w/ a trick! Query: What solutions would this query return? Solutions: Can do a closed-world style of negation!

SPARQL 1.1: (NOT) EXISTS Query: Solutions:

SPARQL 1.1: MINUS Query: Solutions:

Difference between MINUS and NOT EXISTS?

Difference between MINUS and NOT EXISTS? NOT EXISTS: Returns results if right hand side has no matches MINUS: Removes solutions from the left hand side that would join with the right hand side

Difference between MINUS and NOT EXISTS? There is no join between the results! Therefore nothing removed! There is a match! Therefore no results!

New query feature: Property paths

Property paths: regular expressions Only these features cannot be rewritten to something else. These features are “new”, offering arbitrary length paths!

Property paths example: RDF list How to ask: “Which movies are in the Sharknado series?” Query: Solutions:

Property paths example: Finite Bacon number How to ask: “Who has a finite Bacon number?” Query: Solutions: We cannot get the actual Bacon number (path length) for arbitrary length paths

New query feature: Assignment

Assignment with BIND Query: Solutions:

Assignment with VALUES Query: Solutions: No result for ex:Sharknado ex:IanZiering!

New query feature: Aggregates

How to ask: “How many movie stars are in the data?” Aggregates How to ask: “How many movie stars are in the data?”

Aggregates: COUNT Query: Solutions:

DISTINCT applied after COUNT! Aggregates: COUNT Query: Solutions: DISTINCT applied after COUNT!

Aggregates: COUNT Query: Solutions:

How to ask: “How many stars does each movie have?” Aggregates How to ask: “How many stars does each movie have?”

Aggregates: COUNT with GROUP BY Query: Solutions:

How to ask: “Give me movies with more than 1 star?” Aggregates How to ask: “Give me movies with more than 1 star?”

Aggregates: COUNT, GROUP BY, HAVING Query: Solutions: HAVING is like a FILTER for aggregates

Aggregates in SPARQL 1.1 COUNT: Count values SUM: Sum a set of values MIN: Find the lowest value MAX: Find the highest value AVG: Get the average of values GROUP_CONCAT: String-concat values SAMPLE: Select a value (pseudo-randomly)

One more aggregates example: SAMPLE Query: Solutions: OR

Quick note on semantics

Recall from OWL: OWA and lack of UNA

But in SPARQL … Solutions: Query: :hasChild Looks like SPARQL has a UNA and a CWA … But SPARQL does not have “worlds”. It does not interpret “real people”. SPARQL works on data. SPARQL counts RDF terms, not children. ex:Vito :hasChild ex:Connie ex:Sonny ex:Fredo ex:Michael Query: Solutions:

New query feature: Subqueries

How to ask: “How many stars does a movie have on average?” Subqueries How to ask: “How many stars does a movie have on average?”

Subqueries Solutions: Query: Sub-queries useful when you need solution modifiers or aggregates in the middle of a more complex query.

How to ask: “Which movies have more stars than average?” Subqueries How to ask: “Which movies have more stars than average?”

We use ?avg in HAVING clause but it's not part of the GROUP BY Subqueries Query: Solutions: We use ?avg in HAVING clause but it's not part of the GROUP BY

Subqueries Solutions: Query: ?movie in the sub-query is not correlated with ?movie in the outmost query

New query feature: Federation

Endpoints often made public/online

Federation: execute sub-query remotely Get actors for Star Trek movie from LinkedMDB. Use DBpedia to get the birthdate of the actor Can be run at http://sparql.org/sparql.html Example borrowed from: http://www.cambridgesemantics.com/semantic-university/sparql-by-example

New language: SPARQL 1.1 Update

What’s new in SPARQL 1.1? New query features An update language Support for RDFS/OWL entailment New output formats

INSERT DATA default graph

INSERT DATA named graph

DELETE DATA

INSERT/DELETE with WHERE

Combining INSERT/DELETE Solutions for WHERE generated before insertions/deletions Deletions performed before insertions.

Set default update graph: WITH

Simple DELETE WHERE Equivalent to …

Managing named graphs: LOAD LOAD a graph from the Web SILENT: If load fails, suppress error IRI-from: location of graph online IRI-to: local named graph to load into If not given, default graph will be appended Destination graph created if it does not exist (otherwise data are appended) Will fail if RDF cannot be extracted from source graph (unless silent is specified)

Managing named graphs: CLEAR CLEAR all triples from some graph(s) SILENT: If clear fails, suppress error GRAPH IRI: clear specific named graph DEFAULT: clear default graph NAMED: clear all named graphs ALL: clear all graphs Will fail if graph does not exist (unless silent is specified)

Managing named graphs: CREATE CREATE a new blank named graph SILENT: If create fails, suppress error GRAPH IRI: name of graph to create Will fail if graph already exists (unless silent is specified) Existing graphs cannot be affected

Managing named graphs: DROP DROP (remove) some graph(s) SILENT: If drop fails, suppress error GRAPH IRI: name of graph to drop DEFAULT: drop default graph NAMED: drop all named graphs ALL: drop all graphs Will fail if graph does not exist (unless silent is specified) An engine must have a default graph: DROP DEFAULT same as CLEAR DEFAULT

Managing named graphs: COPY COPY one graph to another SILENT: If copy fails, suppress error IRI-from: name of graph to copy from IRI-to: name of graph to copy to DEFAULT: copy from/to default graph May fail if source graph does not exist (unless silent is specified) Destination graph will be created or cleared before the copy is done Source graph unaffected

Managing named graphs: MOVE MOVE one graph to another SILENT: If move fails, suppress error IRI-from: name of graph to move IRI-to: name of graph to move to DEFAULT: move from/to default graph May fail if source graph does not exist (unless silent is specified) Destination graph will be created or cleared before the copy is done Source graph dropped after the move.

Managing named graphs: ADD ADD data from one graph to another SILENT: If add fails, suppress error IRI-from: name of graph to add IRI-to: name of graph to add to DEFAULT: add from/to default graph May fail if source graph does not exist (unless silent is specified) Destination graph created if it does not exist (otherwise data are appended) Source graph unaffected

New feature: SPARQL 1.1 Entailment Regimes

What’s new in SPARQL 1.1? New query features An update language Support for RDFS/OWL entailment New output formats

SPARQL 1.1 Entailment Regimes States how entailments can be included in SPARQL results Support for RDFS / sublanguages of OWL Not well supported (to best of my knowledge) Not going to cover it If interested, check out the book chapter or http://www.w3.org/TR/sparql11-entailment/

New feature: SPARQL 1.1 Output Formats

What’s new in SPARQL 1.1? New query features An update language Support for RDFS/OWL entailment New output formats

SPARQL 1.1 Output Formats SELECT, ASK (non-RDF): XML (1.0), JSON (1.1), CSV/TSV (1.1) CONSTRUCT, DESCRIBE (RDF) Standard RDF syntaxes: RDF/XML, Turtle, etc.

Quick mention: SPARQL 1.1 Protocol

Defines a HTTP protocol How to issue queries/update over HTTP GET / POST How different output formats can be requested Accept: text/turtle, application/rdf+xml What response codes should be returned; e.g. 200 if successful 400 if SPARQL query is invalid 500 if query was okay but server failed to answer … etc. See more details: http://www.w3.org/TR/sparql11-protocol/

SPARQL endpoints on the Web!

SPARQL endpoints on the Web!

Questions?