SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Jarrar: RDFS ( RDF Schema)
Jarrar: RDFS ( RDF Schema) Jarrar: RDFS ( RDF Schema)
Jarrar: RDFS ( RDF Schema)
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
Introduction to Linked Data
Introduction to Linked DataIntroduction to Linked Data
Introduction to Linked Data
 
Debunking some “RDF vs. Property Graph” Alternative Facts
Debunking some “RDF vs. Property Graph” Alternative FactsDebunking some “RDF vs. Property Graph” Alternative Facts
Debunking some “RDF vs. Property Graph” Alternative Facts
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
SHACL by example
SHACL by exampleSHACL by example
SHACL by example
 
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODOLinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
LinkML Intro July 2022.pptx PLEASE VIEW THIS ON ZENODO
 
RDF and OWL
RDF and OWLRDF and OWL
RDF and OWL
 
RDF data model
RDF data modelRDF data model
RDF data model
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)
 
Rdf In A Nutshell V1
Rdf In A Nutshell V1Rdf In A Nutshell V1
Rdf In A Nutshell V1
 
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
Tutorial on SPARQL: SPARQL Protocol and RDF Query Language
 
Querying the Wikidata Knowledge Graph
Querying the Wikidata Knowledge GraphQuerying the Wikidata Knowledge Graph
Querying the Wikidata Knowledge Graph
 
SHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudSHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data Mud
 
Linked Data and Knowledge Graphs -- Constructing and Understanding Knowledge ...
Linked Data and Knowledge Graphs -- Constructing and Understanding Knowledge ...Linked Data and Knowledge Graphs -- Constructing and Understanding Knowledge ...
Linked Data and Knowledge Graphs -- Constructing and Understanding Knowledge ...
 
RDF 개념 및 구문 소개
RDF 개념 및 구문 소개RDF 개념 및 구문 소개
RDF 개념 및 구문 소개
 
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
Linked Data의 RDF 어휘 이해하고 체험하기 - FOAF, SIOC, SKOS를 중심으로 -
 
Querying Linked Data with SPARQL
Querying Linked Data with SPARQLQuerying Linked Data with SPARQL
Querying Linked Data with SPARQL
 

Ähnlich wie SPARQL Tutorial

Ks2007 Semanticweb In Action
Ks2007 Semanticweb In ActionKs2007 Semanticweb In Action
Ks2007 Semanticweb In Action
Rinke Hoekstra
 
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
 
Yokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQLYokohama Art Spot meets SPARQL
Yokohama Art Spot meets SPARQL
Fuyuko Matsumura
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
Emanuele 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 APIs
Josef Petrák
 
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
 
Ks2008 Semanticweb In Action
Ks2008 Semanticweb In ActionKs2008 Semanticweb In Action
Ks2008 Semanticweb In Action
Rinke Hoekstra
 
OpenSearch 2010-09
OpenSearch 2010-09OpenSearch 2010-09
OpenSearch 2010-09
Oscar Fonts
 

Ähnlich wie 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
 

Mehr von Leigh Dodds

Mehr von 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
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

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.