SlideShare une entreprise Scribd logo
1  sur  49
Data Extraction & Exploration with SPARQL & the Talis Platform
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tutorial Schema ,[object Object],[object Object],[object Object]
 
Triple and Graph Patterns ,[object Object]
#An RDF triple in Turtle syntax <http://purl.org/net/schemas/space/spacecraft/1957-001B>   foaf:name “Sputnik 1”.
#An SPARQL triple pattern, with a single variable <http://purl.org/net/schemas/space/spacecraft/1957-001B>   foaf:name ?name.
#All parts of a triple pattern can be variables ?spacecraft   foaf:name ?name.
 
#Matching labels of resources ?subject rdfs:label ?label.
 
#Combine triples patterns to create a graph pattern ?subject rdfs:label ?label. ?subject rdf:type space:Discipline.
#SPARQL is based on Turtle, which allows abbreviations #e.g. predicate-object lists: ?subject rdfs:label ?label; rdf:type space:Discipline.
 
#Graph patterns allow us to traverse a graph ?spacecraft foaf:name “Sputnik 1”. ?launch space:spacecraft ?launch. ?launch space:launched ?launchdate.
#Graph patterns allow us to traverse a graph ?spacecraft foaf:name “Sputnik 1” . ?launch space:spacecraft ?launch . ?launch space:launched ?launchdate .
 
Structure of a Query ,[object Object]
#Ex. 1 #Associate URIs with prefixes PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> #Example of a SELECT query, retrieving 2 variables #Variables selected MUST be bound in graph pattern SELECT ?subject ?label WHERE { #This is our graph pattern ?subject rdfs:label ?label; rdf:type space:Discipline. }
#Ex. 2 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> #Example of a SELECT query, retrieving all variables SELECT * WHERE { ?subject rdfs:label ?label; rdf:type space:Discipline. }
OPTIONAL bindings ,[object Object]
#Ex. 3 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?image WHERE { #This pattern must be bound ?spacecraft foaf:name ?name. #Anything in this block doesn't have to be bound OPTIONAL {   ?spacecraft foaf:depiction ?image. } }
UNION queries ,[object Object]
#Ex. 4 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?subject ?displayLabel WHERE { { ?subject foaf:name ?displayLabel. } UNION { ?subject rdfs:label ?displayLabel. } }
Sorting & Restrictions ,[object Object],[object Object]
#Ex.5  #Select the uri and the mass of all the spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. }
#Ex. 6 #Select the uri and the mass of all the spacecraft #with highest first PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } #Use an ORDER BY clause to apply a sort. Can be ASC or DESC ORDER BY DESC(?mass)‏
#Ex. 7 #Select the uri and the mass of the 10 heaviest spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } #Order by weight descending ORDER BY DESC(?mass)‏ #Limit to first ten results LIMIT 10
#Ex. 8 #Select the uri and the mass of the 11-20 th  most  #heaviest spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } ORDER BY DESC(?mass)‏ #Limit to ten results LIMIT 10 #Apply an offset to get next “page” OFFSET 10
Filtering ,[object Object]
#Sample data for Sputnik launch <http://purl.org/net/schemas/space/launch/1957-001> rdf:type space:Launch; #Assign a datatype to the literal, to indicate it is #a date space:launched &quot;1957-10-04&quot;^^xsd:date; space:spacecraft <http://purl.org/net/schemas/space/spacecraft/1957-001B> .
#Ex. 9 #Select name of spacecraft launched between  #1 st  Jan 1969 and 1 st  Jan 1970 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?launch space:launched ?date; space:spacecraft ?spacecraft. ?spacecraft foaf:name ?name. FILTER (?date > &quot;1969-01-01&quot;^^xsd:date &&  ?date < &quot;1970-01-01&quot;^^xsd:date)‏ }
#Ex. 10 #Select spacecraft with a mass of less than 90kg PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?spacecraft ?name WHERE { ?spacecraft foaf:name ?name; space:mass ?mass. #Note that we have to cast the data to the right type #As it is not declared in the data FILTER( xsd:double(?mass) < 90.0 )‏ }
#Ex. 11 #Select spacecraft with a name like “ollo” PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?spacecraft foaf:name ?name. FILTER( regex(?name, “ollo”, “i” ) )‏ }
Built-In Filters ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
DISTINCT ,[object Object]
#Ex. 12 #Select list of agencies associated with spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT DISTINCT ?agency WHERE { ?spacecraft space:agency ?agency. }
SPARQL Query Forms ,[object Object]
ASK ,[object Object]
#Ex. 13 #Was there a launch on 16 th  July 1969? PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> ASK WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. }
DESCRIBE Generate an RDF description of a resource(s)‏
#Ex. 14 #Describe launch(es) that occurred on 16 th  July 1969 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?launch WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. }
#Ex. 15 #Describe spacecraft launched on 16 th  July 1969 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?spacecraft WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch. }
CONSTRUCT Create a custom RDF graph based on query criteria Can be used to transform RDF data
#Ex. 16 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?spacecraft foaf:name ?name; space:agency ?agency; space:mass ?mass.  } WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch; foaf:name ?name; space:agency ?agency; space:mass ?mass.  }
SELECT SQL style result set retrieval
#Ex. 17 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?agency ?mass WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch; foaf:name ?name; space:agency ?agency; space:mass ?mass.  }
Useful Links ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
shared innovation

Contenu connexe

Tendances

SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020andyseaborne
 
RDFS In A Nutshell V1
RDFS In A Nutshell V1RDFS In A Nutshell V1
RDFS In A Nutshell V1Fabien Gandon
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개Dongbum Kim
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQLOpen Data Support
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFSNilesh Wagmare
 
Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDFNarni Rajesh
 
Inference on the Semantic Web
Inference on the Semantic WebInference on the Semantic Web
Inference on the Semantic WebMyungjin Lee
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage灿辉 葛
 
SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)Thomas Francart
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Fabien Gandon
 
Model Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresModel Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresMarkus Lanthaler
 

Tendances (20)

Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020
 
RDFS In A Nutshell V1
RDFS In A Nutshell V1RDFS In A Nutshell V1
RDFS In A Nutshell V1
 
RDF data model
RDF data modelRDF data model
RDF data model
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개
 
RDF 해설서
RDF 해설서RDF 해설서
RDF 해설서
 
Introduction to RDF & SPARQL
Introduction to RDF & SPARQLIntroduction to RDF & SPARQL
Introduction to RDF & SPARQL
 
RDF validation tutorial
RDF validation tutorialRDF validation tutorial
RDF validation tutorial
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
RDF and OWL
RDF and OWLRDF and OWL
RDF and OWL
 
ShEx vs SHACL
ShEx vs SHACLShEx vs SHACL
ShEx vs SHACL
 
Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDF
 
Inference on the Semantic Web
Inference on the Semantic WebInference on the Semantic Web
Inference on the Semantic Web
 
Rdf data-model-and-storage
Rdf data-model-and-storageRdf data-model-and-storage
Rdf data-model-and-storage
 
SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)
 
SHACL by example
SHACL by exampleSHACL by example
SHACL by example
 
RDF data validation 2017 SHACL
RDF data validation 2017 SHACLRDF data validation 2017 SHACL
RDF data validation 2017 SHACL
 
Model Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresModel Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON Structures
 

Similaire à SPARQL Tutorial

Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialAdonisDamian
 
From SQL to SPARQL
From SQL to SPARQLFrom SQL to SPARQL
From SQL to SPARQLGeorge Roth
 
Ks2007 Semanticweb In Action
Ks2007 Semanticweb In ActionKs2007 Semanticweb In Action
Ks2007 Semanticweb In ActionRinke Hoekstra
 
NoSQL and Triple Stores
NoSQL and Triple StoresNoSQL and Triple Stores
NoSQL and Triple Storesandyseaborne
 
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Jean-Paul Calbimonte
 
Intro to Linked, Dutch Ships and Sailors and SPARQL handson
Intro to Linked, Dutch Ships and Sailors and SPARQL handson Intro to Linked, Dutch Ships and Sailors and SPARQL handson
Intro to Linked, Dutch Ships and Sailors and SPARQL handson Victor de Boer
 
Getting Started With The Talis Platform
Getting Started With The Talis PlatformGetting Started With The Talis Platform
Getting Started With The Talis PlatformLeigh Dodds
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing ServicesLeigh Dodds
 
Yokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQLYokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQLFuyuko Matsumura
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLEmanuele Della Valle
 
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIsJosef Petrák
 
Mashup OpenStreetMap and Wikidata to Create Useful Vector Data
Mashup OpenStreetMap and Wikidata to Create Useful Vector DataMashup OpenStreetMap and Wikidata to Create Useful Vector Data
Mashup OpenStreetMap and Wikidata to Create Useful Vector DataNicholas Peihl
 
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)Olaf Hartig
 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)andyseaborne
 
Geography in Linked Ancient World Data
Geography in Linked Ancient World DataGeography in Linked Ancient World Data
Geography in Linked Ancient World Dataparegorios
 
The Semantics of SPARQL
The Semantics of SPARQLThe Semantics of SPARQL
The Semantics of SPARQLOlaf Hartig
 
Ks2008 Semanticweb In Action
Ks2008 Semanticweb In ActionKs2008 Semanticweb In Action
Ks2008 Semanticweb In ActionRinke Hoekstra
 
OpenSearch 2010-09
OpenSearch 2010-09OpenSearch 2010-09
OpenSearch 2010-09Oscar Fonts
 

Similaire à SPARQL Tutorial (20)

Ontologias - RDF
Ontologias - RDFOntologias - RDF
Ontologias - RDF
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorial
 
From SQL to SPARQL
From SQL to SPARQLFrom SQL to SPARQL
From SQL to SPARQL
 
Ks2007 Semanticweb In Action
Ks2007 Semanticweb In ActionKs2007 Semanticweb In Action
Ks2007 Semanticweb In Action
 
NoSQL and Triple Stores
NoSQL and Triple StoresNoSQL and Triple Stores
NoSQL and Triple Stores
 
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
Tutorial ESWC2011 Building Semantic Sensor Web - 04 - Querying_semantic_strea...
 
Intro to Linked, Dutch Ships and Sailors and SPARQL handson
Intro to Linked, Dutch Ships and Sailors and SPARQL handson Intro to Linked, Dutch Ships and Sailors and SPARQL handson
Intro to Linked, Dutch Ships and Sailors and SPARQL handson
 
Linked Data on Rails
Linked Data on RailsLinked Data on Rails
Linked Data on Rails
 
Getting Started With The Talis Platform
Getting Started With The Talis PlatformGetting Started With The Talis Platform
Getting Started With The Talis Platform
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing Services
 
Yokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQLYokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQL
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
 
Mashup OpenStreetMap and Wikidata to Create Useful Vector Data
Mashup OpenStreetMap and Wikidata to Create Useful Vector DataMashup OpenStreetMap and Wikidata to Create Useful Vector Data
Mashup OpenStreetMap and Wikidata to Create Useful Vector Data
 
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)
(An Overview on) Linked Data Management and SPARQL Querying (ISSLOD2011)
 
SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)SPARQL 1.1 Update (2013-03-05)
SPARQL 1.1 Update (2013-03-05)
 
Geography in Linked Ancient World Data
Geography in Linked Ancient World DataGeography in Linked Ancient World Data
Geography in Linked Ancient World Data
 
The Semantics of SPARQL
The Semantics of SPARQLThe Semantics of SPARQL
The Semantics of SPARQL
 
Ks2008 Semanticweb In Action
Ks2008 Semanticweb In ActionKs2008 Semanticweb In Action
Ks2008 Semanticweb In Action
 
OpenSearch 2010-09
OpenSearch 2010-09OpenSearch 2010-09
OpenSearch 2010-09
 

Plus de Leigh Dodds

Being a data magpie
Being a data magpieBeing a data magpie
Being a data magpieLeigh Dodds
 
How you (yes, you!) can contribute to open data
How you (yes, you!) can contribute to open dataHow you (yes, you!) can contribute to open data
How you (yes, you!) can contribute to open dataLeigh Dodds
 
Accessible Bath Training
Accessible Bath TrainingAccessible Bath Training
Accessible Bath TrainingLeigh Dodds
 
Cheap bots done quick lightning talk
Cheap bots done quick lightning talkCheap bots done quick lightning talk
Cheap bots done quick lightning talkLeigh Dodds
 
Open data in bath
Open data in bathOpen data in bath
Open data in bathLeigh Dodds
 
Bath: Hacked Learning Night: Introduction to CartoDB
Bath: Hacked Learning Night: Introduction to CartoDBBath: Hacked Learning Night: Introduction to CartoDB
Bath: Hacked Learning Night: Introduction to CartoDBLeigh Dodds
 
Dungeons and Dragons and Data
Dungeons and Dragons and DataDungeons and Dragons and Data
Dungeons and Dragons and DataLeigh Dodds
 
Love the Environment Pre-Meetup
Love the Environment Pre-MeetupLove the Environment Pre-Meetup
Love the Environment Pre-MeetupLeigh Dodds
 
Why I love open data and you should too
Why I love open data and you should tooWhy I love open data and you should too
Why I love open data and you should tooLeigh Dodds
 
Introduction to Open Data & Bath: Hacked
Introduction to Open Data & Bath: HackedIntroduction to Open Data & Bath: Hacked
Introduction to Open Data & Bath: HackedLeigh Dodds
 
Bath: Hacked: open data, the arts and cultural heritage
Bath: Hacked: open data, the arts and cultural heritageBath: Hacked: open data, the arts and cultural heritage
Bath: Hacked: open data, the arts and cultural heritageLeigh Dodds
 
Introduction to Open Data & Linked Data
Introduction to Open Data & Linked DataIntroduction to Open Data & Linked Data
Introduction to Open Data & Linked DataLeigh Dodds
 
Time Travelling with Open Data
Time Travelling with Open DataTime Travelling with Open Data
Time Travelling with Open DataLeigh Dodds
 
Ignite for Good: Why I Love Open Data and You Should Too
Ignite for Good: Why I Love Open Data and You Should TooIgnite for Good: Why I Love Open Data and You Should Too
Ignite for Good: Why I Love Open Data and You Should TooLeigh Dodds
 
Oil and Water: When Data Licences Don't Mix
Oil and Water: When Data Licences Don't MixOil and Water: When Data Licences Don't Mix
Oil and Water: When Data Licences Don't MixLeigh Dodds
 
Linked Data Patterns
Linked Data PatternsLinked Data Patterns
Linked Data PatternsLeigh Dodds
 
Digital Grafitti for Digital Cities
Digital Grafitti for Digital CitiesDigital Grafitti for Digital Cities
Digital Grafitti for Digital CitiesLeigh Dodds
 
Layered Data: An Example
Layered Data: An ExampleLayered Data: An Example
Layered Data: An ExampleLeigh Dodds
 
Data Foundations for Digital Cities
Data Foundations for Digital CitiesData Foundations for Digital Cities
Data Foundations for Digital CitiesLeigh Dodds
 

Plus de Leigh Dodds (20)

Being a data magpie
Being a data magpieBeing a data magpie
Being a data magpie
 
How you (yes, you!) can contribute to open data
How you (yes, you!) can contribute to open dataHow you (yes, you!) can contribute to open data
How you (yes, you!) can contribute to open data
 
Accessible Bath Training
Accessible Bath TrainingAccessible Bath Training
Accessible Bath Training
 
Accessible Bath
Accessible BathAccessible Bath
Accessible Bath
 
Cheap bots done quick lightning talk
Cheap bots done quick lightning talkCheap bots done quick lightning talk
Cheap bots done quick lightning talk
 
Open data in bath
Open data in bathOpen data in bath
Open data in bath
 
Bath: Hacked Learning Night: Introduction to CartoDB
Bath: Hacked Learning Night: Introduction to CartoDBBath: Hacked Learning Night: Introduction to CartoDB
Bath: Hacked Learning Night: Introduction to CartoDB
 
Dungeons and Dragons and Data
Dungeons and Dragons and DataDungeons and Dragons and Data
Dungeons and Dragons and Data
 
Love the Environment Pre-Meetup
Love the Environment Pre-MeetupLove the Environment Pre-Meetup
Love the Environment Pre-Meetup
 
Why I love open data and you should too
Why I love open data and you should tooWhy I love open data and you should too
Why I love open data and you should too
 
Introduction to Open Data & Bath: Hacked
Introduction to Open Data & Bath: HackedIntroduction to Open Data & Bath: Hacked
Introduction to Open Data & Bath: Hacked
 
Bath: Hacked: open data, the arts and cultural heritage
Bath: Hacked: open data, the arts and cultural heritageBath: Hacked: open data, the arts and cultural heritage
Bath: Hacked: open data, the arts and cultural heritage
 
Introduction to Open Data & Linked Data
Introduction to Open Data & Linked DataIntroduction to Open Data & Linked Data
Introduction to Open Data & Linked Data
 
Time Travelling with Open Data
Time Travelling with Open DataTime Travelling with Open Data
Time Travelling with Open Data
 
Ignite for Good: Why I Love Open Data and You Should Too
Ignite for Good: Why I Love Open Data and You Should TooIgnite for Good: Why I Love Open Data and You Should Too
Ignite for Good: Why I Love Open Data and You Should Too
 
Oil and Water: When Data Licences Don't Mix
Oil and Water: When Data Licences Don't MixOil and Water: When Data Licences Don't Mix
Oil and Water: When Data Licences Don't Mix
 
Linked Data Patterns
Linked Data PatternsLinked Data Patterns
Linked Data Patterns
 
Digital Grafitti for Digital Cities
Digital Grafitti for Digital CitiesDigital Grafitti for Digital Cities
Digital Grafitti for Digital Cities
 
Layered Data: An Example
Layered Data: An ExampleLayered Data: An Example
Layered Data: An Example
 
Data Foundations for Digital Cities
Data Foundations for Digital CitiesData Foundations for Digital Cities
Data Foundations for Digital Cities
 

Dernier

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Dernier (20)

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

SPARQL Tutorial

  • 1. Data Extraction & Exploration with SPARQL & the Talis Platform
  • 2.
  • 3.
  • 4.  
  • 5.
  • 6. #An RDF triple in Turtle syntax <http://purl.org/net/schemas/space/spacecraft/1957-001B> foaf:name “Sputnik 1”.
  • 7. #An SPARQL triple pattern, with a single variable <http://purl.org/net/schemas/space/spacecraft/1957-001B> foaf:name ?name.
  • 8. #All parts of a triple pattern can be variables ?spacecraft foaf:name ?name.
  • 9.  
  • 10. #Matching labels of resources ?subject rdfs:label ?label.
  • 11.  
  • 12. #Combine triples patterns to create a graph pattern ?subject rdfs:label ?label. ?subject rdf:type space:Discipline.
  • 13. #SPARQL is based on Turtle, which allows abbreviations #e.g. predicate-object lists: ?subject rdfs:label ?label; rdf:type space:Discipline.
  • 14.  
  • 15. #Graph patterns allow us to traverse a graph ?spacecraft foaf:name “Sputnik 1”. ?launch space:spacecraft ?launch. ?launch space:launched ?launchdate.
  • 16. #Graph patterns allow us to traverse a graph ?spacecraft foaf:name “Sputnik 1” . ?launch space:spacecraft ?launch . ?launch space:launched ?launchdate .
  • 17.  
  • 18.
  • 19. #Ex. 1 #Associate URIs with prefixes PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> #Example of a SELECT query, retrieving 2 variables #Variables selected MUST be bound in graph pattern SELECT ?subject ?label WHERE { #This is our graph pattern ?subject rdfs:label ?label; rdf:type space:Discipline. }
  • 20. #Ex. 2 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> #Example of a SELECT query, retrieving all variables SELECT * WHERE { ?subject rdfs:label ?label; rdf:type space:Discipline. }
  • 21.
  • 22. #Ex. 3 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?image WHERE { #This pattern must be bound ?spacecraft foaf:name ?name. #Anything in this block doesn't have to be bound OPTIONAL { ?spacecraft foaf:depiction ?image. } }
  • 23.
  • 24. #Ex. 4 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?subject ?displayLabel WHERE { { ?subject foaf:name ?displayLabel. } UNION { ?subject rdfs:label ?displayLabel. } }
  • 25.
  • 26. #Ex.5 #Select the uri and the mass of all the spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. }
  • 27. #Ex. 6 #Select the uri and the mass of all the spacecraft #with highest first PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } #Use an ORDER BY clause to apply a sort. Can be ASC or DESC ORDER BY DESC(?mass)‏
  • 28. #Ex. 7 #Select the uri and the mass of the 10 heaviest spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } #Order by weight descending ORDER BY DESC(?mass)‏ #Limit to first ten results LIMIT 10
  • 29. #Ex. 8 #Select the uri and the mass of the 11-20 th most #heaviest spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: < http://xmlns.com/foaf/0.1/ > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?spacecraft ?mass WHERE { ?spacecraft space:mass ?mass. } ORDER BY DESC(?mass)‏ #Limit to ten results LIMIT 10 #Apply an offset to get next “page” OFFSET 10
  • 30.
  • 31. #Sample data for Sputnik launch <http://purl.org/net/schemas/space/launch/1957-001> rdf:type space:Launch; #Assign a datatype to the literal, to indicate it is #a date space:launched &quot;1957-10-04&quot;^^xsd:date; space:spacecraft <http://purl.org/net/schemas/space/spacecraft/1957-001B> .
  • 32. #Ex. 9 #Select name of spacecraft launched between #1 st Jan 1969 and 1 st Jan 1970 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?launch space:launched ?date; space:spacecraft ?spacecraft. ?spacecraft foaf:name ?name. FILTER (?date > &quot;1969-01-01&quot;^^xsd:date && ?date < &quot;1970-01-01&quot;^^xsd:date)‏ }
  • 33. #Ex. 10 #Select spacecraft with a mass of less than 90kg PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?spacecraft ?name WHERE { ?spacecraft foaf:name ?name; space:mass ?mass. #Note that we have to cast the data to the right type #As it is not declared in the data FILTER( xsd:double(?mass) < 90.0 )‏ }
  • 34. #Ex. 11 #Select spacecraft with a name like “ollo” PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?spacecraft foaf:name ?name. FILTER( regex(?name, “ollo”, “i” ) )‏ }
  • 35.
  • 36.
  • 37. #Ex. 12 #Select list of agencies associated with spacecraft PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT DISTINCT ?agency WHERE { ?spacecraft space:agency ?agency. }
  • 38.
  • 39.
  • 40. #Ex. 13 #Was there a launch on 16 th July 1969? PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> ASK WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. }
  • 41. DESCRIBE Generate an RDF description of a resource(s)‏
  • 42. #Ex. 14 #Describe launch(es) that occurred on 16 th July 1969 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?launch WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. }
  • 43. #Ex. 15 #Describe spacecraft launched on 16 th July 1969 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?spacecraft WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch. }
  • 44. CONSTRUCT Create a custom RDF graph based on query criteria Can be used to transform RDF data
  • 45. #Ex. 16 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?spacecraft foaf:name ?name; space:agency ?agency; space:mass ?mass. } WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch; foaf:name ?name; space:agency ?agency; space:mass ?mass. }
  • 46. SELECT SQL style result set retrieval
  • 47. #Ex. 17 PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?agency ?mass WHERE { ?launch space:launched &quot;1969-07-16&quot;^^xsd:date. ?spacecraft space:launch ?launch; foaf:name ?name; space:agency ?agency; space:mass ?mass. }
  • 48.