SPARQL + RDF Based on: Prof. Benny Kimelfled’s lecture notes

Slides:



Advertisements
Similar presentations
CH-4 Ontologies, Querying and Data Integration. Introduction to RDF(S) RDF stands for Resource Description Framework. RDF is a standard for describing.
Advertisements

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.
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.
Chapter 3 RDF Syntax 1. Topics Basic concepts of RDF resources, properties, values, statements, triples URIs and URIrefs RDF graphs Literals and Qnames.
SPARQL for Querying PML Data Jitin Arora. Overview SPARQL: Query Language for RDF Graphs W3C Recommendation since 15 January 2008 Outline: Basic Concepts.
LINKED DATA COMS E6125 Prof. Gail Kaiser Presented By : Mandar Mohe ( msm2181 )
Behshid Behkamal Ferdowsi University of Mashhad Web Technology Lab.
Semantic Web Query Processing with Relational Databases Artem Chebotko Department of Computer Science Wayne State University.
1 DCS861A-2007 Emerging IT II Rinaldo Di Giorgio Andres Nieto Chris Nwosisi Richard Washington March 17, 2007.
JOSH FLECK Semantic Web. What is Semantic Web? Movement led by W3C that promotes common formats for data on the web Describes things in a way that computer.
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.
ONTOLOGY SUPPORT For the Semantic Web. THE BIG PICTURE  Diagram, page 9  html5  xml can be used as a syntactic model for RDF and DAML/OIL  RDF, RDF.
1 Ontology Query and Reasoning Payam Barnaghi Institute for Communication Systems (ICS) Faculty of Engineering and Physical Sciences University of Surrey.
Linked Open Data: a new resource for eResearch Dr Anne Cregan eResearch Analyst, Intersect and ANDS
Information Extraction with Linked Life Data 19/04/2011.
Entity Recognition via Querying DBpedia ElShaimaa Ali.
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.
ISBD for the Semantic Web: namespaces, elements, vocabularies, application profile Gordon Dunsire Presented at Centar zu Stalno Stručno Usavršavanje (CSSU),
Semantic Web Applications GoodRelations BBC Artists BBC World Cup 2010 Website Emma Nherera.
Master Informatique 1 Semantic Technologies Part 11Direct Mapping Werner Nutt.
Ontology Query. What is an Ontology Ontologies resemble faceted taxonomies but use richer semantic relationships among terms and attributes, as well as.
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!
Semi-Automatic Quality Assessment of Linked Data without Requiring Ontology Saemi Jang, Megawati, Jiyeon Choi, and Mun Yong Yi KIRD, KAIST NLP&DBPEDIA.
The Promise and Peril of RDF for Formalizing the Humanities James Silas Creel Sarah Potvin Texas A&M University Libraries April 10, 2015 Arlington, Texas.
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,
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.
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.
Of 38 lecture 6: rdf – axiomatic semantics and query.
CC L A W EB DE D ATOS P RIMAVERA 2015 Lecture 7: SPARQL (1.0) Aidan Hogan
Database Management Systems Course Faculty of Computer Science Technion – Israel Institute of Technology Lecture 10: RDF and SPARQL.
A discovery platform for translational research Núria Queralt Rosinach Integrative Biomedical Informatics Group (IBI) Research Programme on Biomedical.
Semantic Web In Depth Resource Description Framework Dr Nicholas Gibbins –
NEDA ALIPANAH, MARIA ADELA GRANDO DBMI 11/19/2012.
Service-Oriented Computing: Semantics, Processes, Agents
Vincenzo Maltese, Fausto Giunchiglia University of Trento
CC La Web de Datos Primavera 2017 Lecture 7: SPARQL [i]
SPARQL.
Service-Oriented Computing: Semantics, Processes, Agents
Service-Oriented Computing: Semantics, Processes, Agents
Database Management Systems
SPARQL SPARQL Protocol and RDF Query Language
Middleware independent Information Service
Query Rewriting Framework for Spatial Data
Supporting Arbitrary Custom Datatypes in RDF and SPARQL
Database Management Systems
Jan Pettersen Nytun, UiA
Grid Computing 7700 Fall 2005 Lecture 18: Semantic Grid
Bus Routes.
Logics for Data and Knowledge Representation
CC La Web de Datos Primavera 2016 Lecture 7: SPARQL (1.0)
Sparql Examples.
Lu Xing CS59000GDM Sept 7th, 2018.
Grid Computing 7700 Fall 2005 Lecture 18: Semantic Grid
DBpedia 2014 Liang Zheng 9.22.
CC La Web de Datos Primavera 2018 Lecture 8: SPARQL [1.1]
Logics for Data and Knowledge Representation
Information - the lifeblood of the business
Linked Data 101 Things, URIs, RDF, Triples, Turtle, Ontologies, Vocabularies and SPARQL Linked Data is our Implementation choice for FAIR.
Linked Data Ryan McAlister.
Presentation transcript:

SPARQL + RDF Based on: Prof. Benny Kimelfled’s lecture notes And Lee Feigenbaum’s “SPARQL By Example” Tutorial “The Semantic Web is an extension of the current web in which information is given well-defined meaning, better enabling computers and people to work in cooperation.” • Vision: Web data will entail semantics in a manner that is understood (and processed, and linked) automatically by computers • The “Semantic Web” is the technical infrastructure – Unambiguous names for resources that may also bind data to real world objects (URI) – A common data model to describe/link resources (RDF) – Expressive language to access to data (SPARQL) – Languages for defining common vocabularies and rules for automated reasoning (e.g., politician is person) (RDFS, OWL) • Data providers should collaborate: properly publish their data and link it to existing data

The Semantic Web Vision: Web data will entail semantics in a manner that is understood (and processed, and linked) automatically by computers Data providers should collaborate: properly publish their data and link it to existing data

Some Freely Available RDF Repositories DBPedia (~1.2b triples) “a crowd-sourced community effort to extract structured information from Wikipedia and make this information available on the Web” Freebase (~340m triples) “A community-curated DB of well-known people, places, and things” DBLP (~58m triples) Computer science bibliography WordNet (~3m triples) English lexical db: synonyms, antonyms, POS, ... GeoNames (~94m triples) “Covers all countries, contains over eight million placenames” Yago (~120m triples) Information from Wikipedia, Wordnet, Geonames

http://lod-cloud.net/

RDF Graph - recap An RDF graph is a finite set of triplets Given two sets: 𝑈 is a set of URIs (unique resource identifier) 𝐿 is a set of literals (strings, integers, etc..) A triplet is in the form (𝑈×𝑈× 𝑈∪𝐿 ) subject object predicate U L

RDF Example from DBPedia http://dbpedia.org/ontology/country http://dbpedia.org/resource/Israel http://dbpedia.org/resource/Petah_Tikva http://dbpedia.org/ontology/birthPlace http://dbpedia.org/ontology/birthPlace http://dbpedia.org/resource/Technion_Israel_Institute_of_Technology http://dbpedia.org/resource/Peretz_Lavie http://dbpedia.org/property/president http://dbpedia.org/property/students http://dbpedia.org/ontology/birthYear 13253 1949

Structure of a SPARQL Query A SPARQL query comprises, in order: Prefix declarations, for abbreviating URIs Dataset definition, stating what RDF graph(s) are being queried A result clause, identifying what information to return from the query The query pattern, specifying what to query for in the underlying dataset Query modifiers, slicing, ordering, and otherwise rearranging query results

Structure of a SPARQL Query # prefix declarations PREFIX foo: <http://example.com/resources/> ... # dataset definition FROM ... # result clause SELECT ... # query pattern WHERE { ... } # query modifiers ORDER BY ...

Endpoints http://yasgui.org/ http://dbpedia.org/sparql

Theory In Practice Yeah, OK, I think I got how the model works…but what about the ACTUAL QUERY?!?! PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) } SELECT DISTINCT ?player ?height { ?player dbo:height ?height

Maccabi Tel Aviv & NBA Players

Basics

Projection SELECT ?x1,...,?xk WHERE {P1} = π{x1,...,xk}(P1(G))

Maccabi Tel Aviv players PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?player { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. } Project out of 𝜇={𝑝𝑙𝑎𝑦𝑒𝑟} URI URI URI / Literal

Join P1 . P2 = P1(G) ⨝ P2(G)

Maccabi’s players and their height Given Retrieve the player’s URI and height Player URI Predicate Maccabi’s URI Player 1 URI dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> … Player n URI Player URI Predicate Height Player 1 URI dbo:height 2 … 1.98 Player n URI 2.10

Maccabi’s players and their height PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?player ?height { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbo:height ?height } Project out of 𝜇={𝑝𝑙𝑎𝑦𝑒𝑟, ℎ𝑒𝑖𝑔ℎ𝑡} Join Create both triplets

P1 OPTIONAL {P2} = P1(G) ⟕ P2(G) Left Outer Join P1 OPTIONAL {P2} = P1(G) ⟕ P2(G)

Maccabi’s players height and nationality PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?player ?height ?nationality { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbo:height ?height OPTIONAL ?player dbp:nationality ?nationality } Project out of 𝜇={𝑝𝑙𝑎𝑦𝑒𝑟, ℎ𝑒𝑖𝑔ℎ𝑡, 𝑛𝑎𝑡𝑖𝑜𝑛𝑎𝑙𝑖𝑡𝑦}

Selection {P1 FILTER ( F )} = σFP1(G)

Maccabi’s players and their teams For each Maccabi’s player, return the player and the team he played in 𝑇𝑒𝑎𝑚 ∈{𝑀𝑎𝑐𝑐𝑎𝑏𝑖, 𝑁𝐵𝐴 𝑡𝑒𝑎𝑚𝑠}

Maccabi’s players and their teams PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) } Project out of 𝜇={𝑝𝑙𝑎𝑦𝑒𝑟, 𝑡𝑒𝑎𝑚, 𝑡𝑦𝑝𝑒} Two joins Filter

{P1} MINUS {P2} = P1(G) - P2(G) Subtraction {P1} MINUS {P2} = P1(G) - P2(G)

Remove all players with height > 2 SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams ) MINUS ?player dbo:height ?height FILTER ( ?height > 2) } 𝜇 1 ={𝑝𝑙𝑎𝑦𝑒𝑟, 𝑡𝑒𝑎𝑚, 𝑡𝑦𝑝𝑒} 𝜇 2 ={𝑝𝑙𝑎𝑦𝑒𝑟, ℎ𝑒𝑖𝑔ℎ𝑡} PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX db: <http://dbpedia.org/> SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) MINUS ?player dbo:height ?height FILTER ( ?height > 2) }

Remove all players with height > 2, and team in NBA SELECT DISTINCT ?player ?team { …..same as before MINUS ?team rdf:type ?type FILTER( ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) } 𝜇 3 ={𝑡𝑒𝑎𝑚, 𝑡𝑦𝑝𝑒} PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX db: <http://dbpedia.org/> SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) MINUS ?player dbo:height ?height FILTER ( ?height > 2) }

Remove….wait… What!? SELECT DISTINCT ?player ?team { Same as before…. MINUS <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> rdf:type ?a } 𝜇 3 ={𝑎} PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX db: <http://dbpedia.org/> SELECT DISTINCT ?player ?team { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ) MINUS <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> rdf:type ?a }

External Graphs – fetch Hebrew names from Wikidata SELECT DISTINCT ?player ?e ?h ?wikidatateam { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?player rdfs:label ?e. ?player owl:sameAs ?wikidatateam FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ). GRAPH <http://www.wikidata.org> ?wikidatateam rdfs:label ?h } FILTER(LANG(?h) = "he" && LANG(?e) = "en") PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX dbp: <http://dbpedia.org/property/> PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT DISTINCT ?player ?e ?h ?wikidatateam { ?player dbp:team <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.>. ?player dbp:team ?team. ?team rdf:type ?type. ?player rdfs:label ?e. ?player owl:sameAs ?wikidatateam FILTER( ?team = <http://dbpedia.org/resource/Maccabi_Tel_Aviv_B.C.> || ?type = <http://dbpedia.org/class/yago/WikicatNationalBasketballAssociationTeams> ). GRAPH <http://www.wikidata.org> ?wikidatateam rdfs:label ?h } FILTER(LANG(?h) = "he" && LANG(?e) = "en")

dbr:Abraham_Lincoln dbo:party dbr:Republican_Party dbr:Whig_Party dbo:profession dbr:Lawyer rdf:type yago:PresidentsOfTheUnitedStates dbr:Franklin_D._Roosevelt dbr:Democratic_Party dbr:Richard_Nixon dbr:Bill_Clinton Ex. 1 SELECT ?president { ?president rdf:type yago:PresidentsOfTheUnitedStates. ?president dbo:profession dbr:Lawyer. } Lincoln Roosevelt Nixon Clinton ?

dbr:Abraham_Lincoln dbo:party dbr:Republican_Party dbr:Whig_Party dbo:profession dbr:Lawyer rdf:type yago:PresidentsOfTheUnitedStates dbr:Franklin_D._Roosevelt dbr:Democratic_Party dbr:Richard_Nixon dbr:Bill_Clinton Ex. 2 SELECT ?president { ?president rdf:type yago:PresidentsOfTheUnitedStates. ?president dbo:profession dbr:Lawyer. OPTIONAL { ?president dbo:party ?party } } Lincoln Roosevelt Nixon Clinton ?

dbr:Abraham_Lincoln dbo:party dbr:Republican_Party dbr:Whig_Party dbo:profession dbr:Lawyer rdf:type yago:PresidentsOfTheUnitedStates dbr:Franklin_D._Roosevelt dbr:Democratic_Party dbr:Richard_Nixon dbr:Bill_Clinton Ex. 3 SELECT ?president { { ?president rdf:type yago:PresidentsOfTheUnitedStates. ?president dbo:profession dbr:Lawyer. OPTIONAL { ?president dbo:party ?party } } MINUS {dbr:Richard_Nixon dbo:party ?party} Lincoln Roosevelt Nixon Clinton ?