SlideShare a Scribd company logo
1 of 31
SPARQL Query Language for RDF Cluj Semantic WEB meetup http://www.meetup.com/Cluj-Semantic-WEB/ presented by  Dia MIRON 17 May 2011
Introduction - SPARQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SPARQL – a first example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SPARQL General Form ORDER BY, DISTINCT  etc (Modifiers) e.g. ORDER BY ?name WHERE  (Query Triple Pattern) e.g. WHERE { ?planttype plant:planttype ?name } FROM  (Data Set) e.g. FROM <http://www.linkeddatatools.com/plantsdata/plants.rdf> SELECT  (Result Set) e.q. SELECT ?name PREFIX  (Namespace Prefixes) e.g. PREFIX plant:<http://www.linkeddatatools.com/plants>
Data set Example: triple data containing a variety of shrubs and plants, and their family names
Select All Data ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
And the results are… ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],29.         <binding name=&quot;family&quot;> 30.            <literal>Aralianae</literal> 31.         </binding> 32.      </result> 33.      <result> 34.         <binding name=&quot;name&quot;> 35.            <uri>http://www.linkeddatatools.com/plants#velvetleaf</uri> 36.         </binding> 37.         <binding name=&quot;family&quot;> 38.            <literal>Malvaceae</literal> 39.         </binding> 40.      </result> 41.      <result> 42.         <binding name=&quot;name&quot;> 43.            <uri>http://www.linkeddatatools.com/plants#manglietia</uri> 44.         </binding> 45.         <binding name=&quot;family&quot;> 46.            <literal>Magnoliaceae</literal> 47.         </binding> 48.      </result> 49.   </results> 50.</sparql>
A more specific query ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What About CREATE, INSERT, UPDATE? ,[object Object],[object Object],[object Object]
Basic Graph Pattern  - Multiple Matches Group Graph Pattern  (set of graph patterns) also! Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/>  SELECT ?name ?mbox  WHERE  { ?x foaf:name ?name .  ?x foaf:mbox ?mbox }   @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Johnny Lee Outlaw&quot; .  _:a foaf:mbox <mailto:jlow@example.com> .  _:b foaf:name &quot;Peter Goodguy&quot; .  _:b foaf:mbox <mailto:peter@example.org> . <mailto:peter@example.org> &quot;Peter Goodguy&quot; <mailto:jlow@example.com> &quot;Johnny Lee Outlaw&quot; mbox name
Basic Graph Pattern  - Blank Nodes Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?x ?name  WHERE { ?x foaf:name ?name }  @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Alice&quot; .  _:b foaf:name &quot;Bob&quot; .  “ Bob” _:d “ Alice“ _:c name x
Value Constraints Data Query Query Result PREFIX dc: <http://purl.org/dc/elements/1.1/>  PREFIX ns: <http://example.org/ns#>  SELECT ?title ?price  WHERE { ?x ns:price ?price .  FILTER ?price < 30 .  ?x dc:title ?title . }  @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> .  :book1 dc:title &quot;SPARQL Tutorial&quot; .  :book1 ns:price 42 .  :book2 dc:title &quot;The Semantic Web&quot; .  :book2 ns:price 23  .  23 &quot;The Semantic Web&quot;  price title
Optional graph patterns Data Query Query Result PREFIX dc: <http://purl.org/dc/elements/1.1/>  PREFIX ns: <http://example.org/ns#>  SELECT ?title ?price  WHERE { ?x dc:title ?title .  OPTIONAL { ?x ns:price ?price .  FILTER ?price < 30 }} @prefix dc: <http://purl.org/dc/elements/1.1/> .  @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> .  :book1 dc:title &quot;SPARQL Tutorial&quot; .  :book1 ns:price 42 .  :book2 dc:title &quot;The Semantic Web&quot; . :book2 ns:price 23  .  “ SPARQL Tutorial“ 23 &quot;The Semantic Web&quot;  price title
Multiple Optional Blocks Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/>  SELECT ?name ?mbox ?hpage  WHERE { ?x foaf:name ?name .  OPTIONAL { ?x foaf:mbox ?mbox }.  OPTIONAL { ?x foaf:homepage ?hpage } }  @prefix foaf: <http://xmlns.com/foaf/0.1/> .  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .  _:a foaf:name &quot;Alice&quot; .  _:a foaf:homepage <http://work.example.org/alice/> .  _:b foaf:name &quot;Bob&quot; .  _:b foaf:mbox <mailto:bob@work.example> .  <mailto:bob@example.com>  “ Bob“ <http://work.example.org/alice/>  “ Alice“ hpage Mbox name
Alternative Graph Patterns Data Query Query Result PREFIX dc10: <http://purl.org/dc/elements/1.0/>  PREFIX dc11: <http://purl.org/dc/elements/1.1/> SELECT ?x ?y  WHERE { { ?book dc10:title ?x } UNION { ?book dc11:title ?y } }  @prefix dc10: <http://purl.org/dc/elements/1.0/> . @prefix dc11: <http://purl.org/dc/elements/1.1/> .  _:a dc10:title &quot;SPARQL Query Language Tutorial&quot; .  _:b dc11:title &quot;SPARQL Protocol Tutorial&quot; .  _:c dc10:title &quot;SPARQL&quot; .  _:c dc11:title &quot;SPARQL (updated)&quot; .  y x &quot;SPARQL (updated)&quot;  &quot;SPARQL Query Language Tutorial&quot;  &quot;SPARQL&quot;  &quot;SPARQL Protocol Tutorial&quot;
RDF Dataset ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
RDF Dataset- T he Relationship between Named and Background Graphs (I) #  Background graph   @prefix dc: <http://purl.org/dc/elements/1.1/> .  <http://example.org/bob> dc:publisher &quot;Bob&quot; .  <http://example.org/alice> dc:publisher &quot;Alice&quot; .  #  Graph: http://example.org/bob   @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Bob&quot; .  _:a foaf:mbox <mailto:bob@oldcorp.example.org> . #  Graph: http://example.org/alice   @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Alice&quot; .  _:a foaf:mbox <mailto:alice@work.example.org>  .
RDF Dataset- T he Relationship between Named and Background Graphs (II) #  Background graph   @prefix foaf: <http://xmlns.com/foaf/0.1/>   .  _:x foaf:name &quot;Bob&quot; .  _:x foaf:mbox <mailto:bob@oldcorp.example.org> . _:y foaf:name &quot;Alice&quot; .  _:y foaf:mbox <mailto:alice@work.example.org> .  #  Graph: http://example.org/bob   @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Bob&quot; .  _:a foaf:mbox <mailto:bob@oldcorp.example.org> . #  Graph: http://example.org/alice   @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Alice&quot; .  _:a foaf:mbox <mailto:alice@work.example.org>  .
Querying the Dataset # Graph: http://example.org/foaf/aliceFoaf  @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .  _:a foaf:name &quot;Alice&quot; .  _:a foaf:mbox <mailto:alice@work.example> .  _:a foaf:knows _:b .  _:b rdfs:seeAlso <http://example.org/foaf/bobFoaf> .  <http://example.org/foaf/bobFoaf> rdf:type foaf:PersonalProfileDocument .  _:b foaf:name &quot;Bob&quot; .  _:b foaf:mbox <mailto:bob@work.example> .  _:b foaf:age 32 .  # Graph: http://example.org/foaf/bobFoaf  @prefix foaf: <http://xmlns.com/foaf/0.1/> .  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . _:1 foaf:mbox <mailto:bob@work.example> . _:1 rdfs:seeAlso <http://example.org/foaf/bobFoaf> .  _:1 foaf:age 35 .  <http://example.org/foaf/bobFoaf> rdf:type foaf:PersonalProfileDocument .
Querying the Dataset  - Accessing Graph Labels PREFIX foaf: <http://xmlns.com/foaf/0.1/>  SELECT ?src ?bobAge  WHERE { GRAPH ?src  { ?x foaf:mbox <mailto:bob@work.example> .  ?x foaf:age ?bobAge } } 35  <http://example.org/foaf/bobFoaf>  32  <http://example.org/foaf/aliceFoaf>  bobAge src
Querying the Dataset  -  Restricting by Graph Label  PREFIX foaf: <http://xmlns.com/foaf/0.1/>  PREFIX data: <http://example.org/foaf/>  SELECT ?age  WHERE  { GRAPH data:bobFoaf  {  ?x foaf:mbox <mailto:bob@work.example> .  ?x foaf:age ?age  }  } 35 age
Querying the Dataset  -  Restricting via Query Pattern  PREFIX data: <http://example.org/foaf/>  PREFIX foaf: <http://xmlns.com/foaf/0.1/>  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>  SELECT ?mbox ?age ?ppd  WHERE  { GRAPH data:aliceFoaf  { ?alice foaf:mbox <mailto:alice@work.example> ; foaf:knows ?whom .  ?whom foaf:mbox ?mbox ;  rdfs:seeAlso ?ppd .  ?ppd a foaf:PersonalProfileDocument . } .  GRAPH ?ppd { ?w foaf:mbox ?mbox ;  foaf:age ?age } }  <http://example.org/foaf/bobFoaf>  35  <mailto:bob@work.example>  ppd age mbox
Query Execution and Ordering  ,[object Object],[object Object],[object Object]
Query forms:   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CONSTRUCT Examples(I) PREFIX foaf: <http://xmlns.com/foaf/0.1/>  PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>  CONSTRUCT { <http://example.org/person#Alice> vcard:FN ?name }  WHERE { ?x foaf:name ?name }  @prefix foaf: <http://xmlns.com/foaf/0.1/> .  _:a foaf:name &quot;Alice&quot; . _:a foaf:mbox <mailto:alice@example.org> . @prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>. <http://example.org/person#Alice> vcard:FN &quot;Alice&quot; . #extracting a whole graph from the target RDF dataset CONSTRUCT { ?s ?p ?o }  WHERE { GRAPH <http://example.org/myGraph> { ?s ?p ?o } . }
CONSTRUCT Examples(II) accesing a graph conditional on other information contained in the metadata about named graphs in the dataset PREFIX dc: <http://purl.org/dc/elements/1.1/>  PREFIX app: <http://example.org/ns#>  CONSTRUCT { ?s ?p ?o }  WHERE { GRAPH ?g { ?s ?p ?o } .  { ?g dc:publisher <http://www.w3.org/> } .  { ?g dc:date ?date } .  FILTER app:myDate(?date) > &quot;2005-02-8T00:00:00Z&quot;^^xsd:dateTime.  }
DESCRIBE PREFIX ent: <http://myorg.example/employees#> DESCRIBE ?x WHERE { ?x ent:employeeId &quot;1234&quot; }  @prefix foaf: <http://xmlns.com/foaf/0.1/> .  @prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0> .  @prefix myOrg: <http://myorg.example/employees#> . _:a myOrg:employeeId &quot;1234&quot; ;  foaf:mbox_sha1sum &quot;ABCD1234&quot; ;  vcard:N [ vcard:Family &quot;Smith&quot; ;  vcard:Given &quot;John&quot; ] .  foaf:mbox_sha1sum rdf:type owl:InverseFunctionalProperty .
ASK @prefix foaf: <http://xmlns.com/foaf/0.1/> .  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .  _:a foaf:name &quot;Alice&quot; .  _:a foaf:homepage <http://work.example.org/alice/> .  _:b foaf:name &quot;Bob&quot; .  _:b foaf:mbox <mailto:bob@work.example> . PREFIX foaf: <http://xmlns.com/foaf/0.1/>  ASK { ?x foaf:name &quot;Alice&quot; } .
Testing Values ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Support for SPARQL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contact ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

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
 
Linking the world with Python and Semantics
Linking the world with Python and SemanticsLinking the world with Python and Semantics
Linking the world with Python and SemanticsTatiana Al-Chueyr
 
Graph Data -- RDF and Property Graphs
Graph Data -- RDF and Property GraphsGraph Data -- RDF and Property Graphs
Graph Data -- RDF and Property Graphsandyseaborne
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031kwangsub kim
 
Two graph data models : RDF and Property Graphs
Two graph data models : RDF and Property GraphsTwo graph data models : RDF and Property Graphs
Two graph data models : RDF and Property Graphsandyseaborne
 
NoSQL and Triple Stores
NoSQL and Triple StoresNoSQL and Triple Stores
NoSQL and Triple Storesandyseaborne
 
Aidan's PhD Viva
Aidan's PhD VivaAidan's PhD Viva
Aidan's PhD VivaAidan Hogan
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapesJose Emilio Labra Gayo
 
Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1net2-project
 
Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02eswcsummerschool
 
SWT Lecture Session 9 - RDB2RDF direct mapping
SWT Lecture Session 9 - RDB2RDF direct mappingSWT Lecture Session 9 - RDB2RDF direct mapping
SWT Lecture Session 9 - RDB2RDF direct mappingMariano Rodriguez-Muro
 
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationVladimir Alexiev, PhD, PMP
 

What's hot (20)

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)
 
Linking the world with Python and Semantics
Linking the world with Python and SemanticsLinking the world with Python and Semantics
Linking the world with Python and Semantics
 
SPARQL 1.1 Status
SPARQL 1.1 StatusSPARQL 1.1 Status
SPARQL 1.1 Status
 
Graph Data -- RDF and Property Graphs
Graph Data -- RDF and Property GraphsGraph Data -- RDF and Property Graphs
Graph Data -- RDF and Property Graphs
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
4 sw architectures and sparql
4 sw architectures and sparql4 sw architectures and sparql
4 sw architectures and sparql
 
RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031
 
Two graph data models : RDF and Property Graphs
Two graph data models : RDF and Property GraphsTwo graph data models : RDF and Property Graphs
Two graph data models : RDF and Property Graphs
 
NoSQL and Triple Stores
NoSQL and Triple StoresNoSQL and Triple Stores
NoSQL and Triple Stores
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Aidan's PhD Viva
Aidan's PhD VivaAidan's PhD Viva
Aidan's PhD Viva
 
Challenges and applications of RDF shapes
Challenges and applications of RDF shapesChallenges and applications of RDF shapes
Challenges and applications of RDF shapes
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1Federation and Navigation in SPARQL 1.1
Federation and Navigation in SPARQL 1.1
 
SWT Lecture Session 10 R2RML Part 1
SWT Lecture Session 10 R2RML Part 1SWT Lecture Session 10 R2RML Part 1
SWT Lecture Session 10 R2RML Part 1
 
SWT Lecture Session 3 - SPARQL
SWT Lecture Session 3 - SPARQLSWT Lecture Session 3 - SPARQL
SWT Lecture Session 3 - SPARQL
 
Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02Mon norton tut_queryinglinkeddata02
Mon norton tut_queryinglinkeddata02
 
SWT Lecture Session 9 - RDB2RDF direct mapping
SWT Lecture Session 9 - RDB2RDF direct mappingSWT Lecture Session 9 - RDB2RDF direct mapping
SWT Lecture Session 9 - RDB2RDF direct mapping
 
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic RepresentationGetty Vocabulary Program LOD: Ontologies and Semantic Representation
Getty Vocabulary Program LOD: Ontologies and Semantic Representation
 
SWT Lecture Session 11 - R2RML part 2
SWT Lecture Session 11 - R2RML part 2SWT Lecture Session 11 - R2RML part 2
SWT Lecture Session 11 - R2RML part 2
 

Viewers also liked

[DSBW Spring 2010] Unit 10: XML and Web And beyond
[DSBW Spring 2010] Unit 10: XML and Web And beyond[DSBW Spring 2010] Unit 10: XML and Web And beyond
[DSBW Spring 2010] Unit 10: XML and Web And beyondCarles Farré
 
New Yarns and Funny Jokes
New Yarns and Funny JokesNew Yarns and Funny Jokes
New Yarns and Funny JokesChuck Thompson
 
malagigi
malagigimalagigi
malagigiuokko
 
Salute e scuola
Salute e scuolaSalute e scuola
Salute e scuolasepulvi
 
Meducate® GI Patient Education Brochures
Meducate® GI Patient Education BrochuresMeducate® GI Patient Education Brochures
Meducate® GI Patient Education BrochuresGI Supply
 
08 newton's law of motion
08 newton's law of motion08 newton's law of motion
08 newton's law of motionIZZUDIN IBRAHIM
 
Mangan i hrom
Mangan i hrom Mangan i hrom
Mangan i hrom vukpro97
 
Guia de_derecho_romano
Guia  de_derecho_romanoGuia  de_derecho_romano
Guia de_derecho_romanoMariana Muñoz
 
Malingering and how to spot it
Malingering and how to spot itMalingering and how to spot it
Malingering and how to spot itNelson Hendler
 
Parní lokomotivy čsd
Parní lokomotivy čsdParní lokomotivy čsd
Parní lokomotivy čsdcorvik
 
Te Reo o Ngatihine
Te Reo o NgatihineTe Reo o Ngatihine
Te Reo o Ngatihinekiamataara
 
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...Maghrenov
 
Subphylum mandibulata (By: J.Q)
Subphylum mandibulata (By: J.Q)Subphylum mandibulata (By: J.Q)
Subphylum mandibulata (By: J.Q)Josefino Quieta
 
Martensitic stainless steel
Martensitic stainless steel Martensitic stainless steel
Martensitic stainless steel thiru1mech
 

Viewers also liked (20)

SQL2SPARQL
SQL2SPARQLSQL2SPARQL
SQL2SPARQL
 
[DSBW Spring 2010] Unit 10: XML and Web And beyond
[DSBW Spring 2010] Unit 10: XML and Web And beyond[DSBW Spring 2010] Unit 10: XML and Web And beyond
[DSBW Spring 2010] Unit 10: XML and Web And beyond
 
New Yarns and Funny Jokes
New Yarns and Funny JokesNew Yarns and Funny Jokes
New Yarns and Funny Jokes
 
Trafiklab Meetup 20161206
Trafiklab Meetup 20161206Trafiklab Meetup 20161206
Trafiklab Meetup 20161206
 
malagigi
malagigimalagigi
malagigi
 
Salute e scuola
Salute e scuolaSalute e scuola
Salute e scuola
 
Brachyura
BrachyuraBrachyura
Brachyura
 
Meducate® GI Patient Education Brochures
Meducate® GI Patient Education BrochuresMeducate® GI Patient Education Brochures
Meducate® GI Patient Education Brochures
 
08 newton's law of motion
08 newton's law of motion08 newton's law of motion
08 newton's law of motion
 
Mandible # brief
Mandible # brief Mandible # brief
Mandible # brief
 
Mangan i hrom
Mangan i hrom Mangan i hrom
Mangan i hrom
 
Guia de_derecho_romano
Guia  de_derecho_romanoGuia  de_derecho_romano
Guia de_derecho_romano
 
Malingering and how to spot it
Malingering and how to spot itMalingering and how to spot it
Malingering and how to spot it
 
carnivora dan proboscidea
carnivora dan proboscidea carnivora dan proboscidea
carnivora dan proboscidea
 
Parní lokomotivy čsd
Parní lokomotivy čsdParní lokomotivy čsd
Parní lokomotivy čsd
 
Te Reo o Ngatihine
Te Reo o NgatihineTe Reo o Ngatihine
Te Reo o Ngatihine
 
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...
MAGHRENOV deliverable 2.1: Roadmap of an EU-MPC entrepreneurial education pro...
 
Subphylum mandibulata (By: J.Q)
Subphylum mandibulata (By: J.Q)Subphylum mandibulata (By: J.Q)
Subphylum mandibulata (By: J.Q)
 
Martensitic stainless steel
Martensitic stainless steel Martensitic stainless steel
Martensitic stainless steel
 
E-nano Newsletter 32
E-nano Newsletter 32E-nano Newsletter 32
E-nano Newsletter 32
 

Similar to From SQL to SPARQL

The Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLThe Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLMyungjin Lee
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDFLeigh Dodds
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDFLeigh Dodds
 
Sparql a simple knowledge query
Sparql  a simple knowledge querySparql  a simple knowledge query
Sparql a simple knowledge queryStanley Wang
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing ServicesLeigh Dodds
 
Gist od2-feb-2011
Gist od2-feb-2011Gist od2-feb-2011
Gist od2-feb-2011ianibbo
 
Exploiter le Web Semantic, le comprendre et y contribuer
Exploiter le Web Semantic, le comprendre et y contribuerExploiter le Web Semantic, le comprendre et y contribuer
Exploiter le Web Semantic, le comprendre et y contribuerMathieu d'Aquin
 
Building linked data apps
Building linked data appsBuilding linked data apps
Building linked data appsHenk Jurriens
 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Juan Sequeda
 
Semantic Web
Semantic WebSemantic Web
Semantic Webhardchiu
 
Visualize open data with Plone - eea.daviz PLOG 2013
Visualize open data with Plone - eea.daviz PLOG 2013Visualize open data with Plone - eea.daviz PLOG 2013
Visualize open data with Plone - eea.daviz PLOG 2013Antonio De Marinis
 
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
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQLPedro Szekely
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP yucefmerhi
 
The Web, one huge database ...
The Web, one huge database ...The Web, one huge database ...
The Web, one huge database ...Michael Hausenblas
 
Architecting Web Services
Architecting Web ServicesArchitecting Web Services
Architecting Web ServicesLorna Mitchell
 

Similar to From SQL to SPARQL (20)

The Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLThe Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQL
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
 
Sparql a simple knowledge query
Sparql  a simple knowledge querySparql  a simple knowledge query
Sparql a simple knowledge query
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing Services
 
Gist od2-feb-2011
Gist od2-feb-2011Gist od2-feb-2011
Gist od2-feb-2011
 
Exploiter le Web Semantic, le comprendre et y contribuer
Exploiter le Web Semantic, le comprendre et y contribuerExploiter le Web Semantic, le comprendre et y contribuer
Exploiter le Web Semantic, le comprendre et y contribuer
 
Building linked data apps
Building linked data appsBuilding linked data apps
Building linked data apps
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011
 
W3 C Specification For Interoperability And Accessibility For Ajax, Dhtml, Xm...
W3 C Specification For Interoperability And Accessibility For Ajax, Dhtml, Xm...W3 C Specification For Interoperability And Accessibility For Ajax, Dhtml, Xm...
W3 C Specification For Interoperability And Accessibility For Ajax, Dhtml, Xm...
 
Semantic Web
Semantic WebSemantic Web
Semantic Web
 
Web 3 0
Web 3 0Web 3 0
Web 3 0
 
Visualize open data with Plone - eea.daviz PLOG 2013
Visualize open data with Plone - eea.daviz PLOG 2013Visualize open data with Plone - eea.daviz PLOG 2013
Visualize open data with Plone - eea.daviz PLOG 2013
 
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
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 
The Web, one huge database ...
The Web, one huge database ...The Web, one huge database ...
The Web, one huge database ...
 
Architecting Web Services
Architecting Web ServicesArchitecting Web Services
Architecting Web Services
 

Recently uploaded

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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 slidevu2urc
 
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...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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 SolutionsEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

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...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

From SQL to SPARQL

  • 1. SPARQL Query Language for RDF Cluj Semantic WEB meetup http://www.meetup.com/Cluj-Semantic-WEB/ presented by Dia MIRON 17 May 2011
  • 2.
  • 3.
  • 4. SPARQL General Form ORDER BY, DISTINCT etc (Modifiers) e.g. ORDER BY ?name WHERE (Query Triple Pattern) e.g. WHERE { ?planttype plant:planttype ?name } FROM (Data Set) e.g. FROM <http://www.linkeddatatools.com/plantsdata/plants.rdf> SELECT (Result Set) e.q. SELECT ?name PREFIX (Namespace Prefixes) e.g. PREFIX plant:<http://www.linkeddatatools.com/plants>
  • 5. Data set Example: triple data containing a variety of shrubs and plants, and their family names
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Basic Graph Pattern - Multiple Matches Group Graph Pattern (set of graph patterns) also! Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox WHERE { ?x foaf:name ?name . ?x foaf:mbox ?mbox } @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Johnny Lee Outlaw&quot; . _:a foaf:mbox <mailto:jlow@example.com> . _:b foaf:name &quot;Peter Goodguy&quot; . _:b foaf:mbox <mailto:peter@example.org> . <mailto:peter@example.org> &quot;Peter Goodguy&quot; <mailto:jlow@example.com> &quot;Johnny Lee Outlaw&quot; mbox name
  • 11. Basic Graph Pattern - Blank Nodes Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?x ?name WHERE { ?x foaf:name ?name } @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Alice&quot; . _:b foaf:name &quot;Bob&quot; . “ Bob” _:d “ Alice“ _:c name x
  • 12. Value Constraints Data Query Query Result PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> SELECT ?title ?price WHERE { ?x ns:price ?price . FILTER ?price < 30 . ?x dc:title ?title . } @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> . :book1 dc:title &quot;SPARQL Tutorial&quot; . :book1 ns:price 42 . :book2 dc:title &quot;The Semantic Web&quot; . :book2 ns:price 23 . 23 &quot;The Semantic Web&quot; price title
  • 13. Optional graph patterns Data Query Query Result PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX ns: <http://example.org/ns#> SELECT ?title ?price WHERE { ?x dc:title ?title . OPTIONAL { ?x ns:price ?price . FILTER ?price < 30 }} @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix : <http://example.org/book/> . @prefix ns: <http://example.org/ns#> . :book1 dc:title &quot;SPARQL Tutorial&quot; . :book1 ns:price 42 . :book2 dc:title &quot;The Semantic Web&quot; . :book2 ns:price 23 . “ SPARQL Tutorial“ 23 &quot;The Semantic Web&quot; price title
  • 14. Multiple Optional Blocks Data Query Query Result PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox ?hpage WHERE { ?x foaf:name ?name . OPTIONAL { ?x foaf:mbox ?mbox }. OPTIONAL { ?x foaf:homepage ?hpage } } @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . _:a foaf:name &quot;Alice&quot; . _:a foaf:homepage <http://work.example.org/alice/> . _:b foaf:name &quot;Bob&quot; . _:b foaf:mbox <mailto:bob@work.example> . <mailto:bob@example.com> “ Bob“ <http://work.example.org/alice/> “ Alice“ hpage Mbox name
  • 15. Alternative Graph Patterns Data Query Query Result PREFIX dc10: <http://purl.org/dc/elements/1.0/> PREFIX dc11: <http://purl.org/dc/elements/1.1/> SELECT ?x ?y WHERE { { ?book dc10:title ?x } UNION { ?book dc11:title ?y } } @prefix dc10: <http://purl.org/dc/elements/1.0/> . @prefix dc11: <http://purl.org/dc/elements/1.1/> . _:a dc10:title &quot;SPARQL Query Language Tutorial&quot; . _:b dc11:title &quot;SPARQL Protocol Tutorial&quot; . _:c dc10:title &quot;SPARQL&quot; . _:c dc11:title &quot;SPARQL (updated)&quot; . y x &quot;SPARQL (updated)&quot; &quot;SPARQL Query Language Tutorial&quot; &quot;SPARQL&quot; &quot;SPARQL Protocol Tutorial&quot;
  • 16.
  • 17. RDF Dataset- T he Relationship between Named and Background Graphs (I) # Background graph @prefix dc: <http://purl.org/dc/elements/1.1/> . <http://example.org/bob> dc:publisher &quot;Bob&quot; . <http://example.org/alice> dc:publisher &quot;Alice&quot; . # Graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Bob&quot; . _:a foaf:mbox <mailto:bob@oldcorp.example.org> . # Graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Alice&quot; . _:a foaf:mbox <mailto:alice@work.example.org> .
  • 18. RDF Dataset- T he Relationship between Named and Background Graphs (II) # Background graph @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:x foaf:name &quot;Bob&quot; . _:x foaf:mbox <mailto:bob@oldcorp.example.org> . _:y foaf:name &quot;Alice&quot; . _:y foaf:mbox <mailto:alice@work.example.org> . # Graph: http://example.org/bob @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Bob&quot; . _:a foaf:mbox <mailto:bob@oldcorp.example.org> . # Graph: http://example.org/alice @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Alice&quot; . _:a foaf:mbox <mailto:alice@work.example.org> .
  • 19. Querying the Dataset # Graph: http://example.org/foaf/aliceFoaf @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . _:a foaf:name &quot;Alice&quot; . _:a foaf:mbox <mailto:alice@work.example> . _:a foaf:knows _:b . _:b rdfs:seeAlso <http://example.org/foaf/bobFoaf> . <http://example.org/foaf/bobFoaf> rdf:type foaf:PersonalProfileDocument . _:b foaf:name &quot;Bob&quot; . _:b foaf:mbox <mailto:bob@work.example> . _:b foaf:age 32 . # Graph: http://example.org/foaf/bobFoaf @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . _:1 foaf:mbox <mailto:bob@work.example> . _:1 rdfs:seeAlso <http://example.org/foaf/bobFoaf> . _:1 foaf:age 35 . <http://example.org/foaf/bobFoaf> rdf:type foaf:PersonalProfileDocument .
  • 20. Querying the Dataset - Accessing Graph Labels PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?src ?bobAge WHERE { GRAPH ?src { ?x foaf:mbox <mailto:bob@work.example> . ?x foaf:age ?bobAge } } 35 <http://example.org/foaf/bobFoaf> 32 <http://example.org/foaf/aliceFoaf> bobAge src
  • 21. Querying the Dataset - Restricting by Graph Label PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX data: <http://example.org/foaf/> SELECT ?age WHERE { GRAPH data:bobFoaf { ?x foaf:mbox <mailto:bob@work.example> . ?x foaf:age ?age } } 35 age
  • 22. Querying the Dataset - Restricting via Query Pattern PREFIX data: <http://example.org/foaf/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?mbox ?age ?ppd WHERE { GRAPH data:aliceFoaf { ?alice foaf:mbox <mailto:alice@work.example> ; foaf:knows ?whom . ?whom foaf:mbox ?mbox ; rdfs:seeAlso ?ppd . ?ppd a foaf:PersonalProfileDocument . } . GRAPH ?ppd { ?w foaf:mbox ?mbox ; foaf:age ?age } } <http://example.org/foaf/bobFoaf> 35 <mailto:bob@work.example> ppd age mbox
  • 23.
  • 24.
  • 25. CONSTRUCT Examples(I) PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> CONSTRUCT { <http://example.org/person#Alice> vcard:FN ?name } WHERE { ?x foaf:name ?name } @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name &quot;Alice&quot; . _:a foaf:mbox <mailto:alice@example.org> . @prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>. <http://example.org/person#Alice> vcard:FN &quot;Alice&quot; . #extracting a whole graph from the target RDF dataset CONSTRUCT { ?s ?p ?o } WHERE { GRAPH <http://example.org/myGraph> { ?s ?p ?o } . }
  • 26. CONSTRUCT Examples(II) accesing a graph conditional on other information contained in the metadata about named graphs in the dataset PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX app: <http://example.org/ns#> CONSTRUCT { ?s ?p ?o } WHERE { GRAPH ?g { ?s ?p ?o } . { ?g dc:publisher <http://www.w3.org/> } . { ?g dc:date ?date } . FILTER app:myDate(?date) > &quot;2005-02-8T00:00:00Z&quot;^^xsd:dateTime. }
  • 27. DESCRIBE PREFIX ent: <http://myorg.example/employees#> DESCRIBE ?x WHERE { ?x ent:employeeId &quot;1234&quot; } @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0> . @prefix myOrg: <http://myorg.example/employees#> . _:a myOrg:employeeId &quot;1234&quot; ; foaf:mbox_sha1sum &quot;ABCD1234&quot; ; vcard:N [ vcard:Family &quot;Smith&quot; ; vcard:Given &quot;John&quot; ] . foaf:mbox_sha1sum rdf:type owl:InverseFunctionalProperty .
  • 28. ASK @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . _:a foaf:name &quot;Alice&quot; . _:a foaf:homepage <http://work.example.org/alice/> . _:b foaf:name &quot;Bob&quot; . _:b foaf:mbox <mailto:bob@work.example> . PREFIX foaf: <http://xmlns.com/foaf/0.1/> ASK { ?x foaf:name &quot;Alice&quot; } .
  • 29.
  • 30.
  • 31.