- Last modified: 2012-05-05
- This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License, with attribution to W3C and Cambridge Semantics.
- This talk: <http://w3.org/brief/MjQx>
most of the world's data
is in documents
machine-useful data
is in RDBs
today's questions
link RDBs
SERVICE <http://uu3.org:8888/7tm_receptors> { ?iuphar iface:family ?family . ?iuphar iface:code ?code . ?iuphar iface:iupharName ?iupharNm . ?human iface:iuphar ?iuphar . ?human iface:geneName "GABBR1" . ?human iface:entrezGene ?humanEntrez . } SERVICE <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&> { _:gene dbp:entrezgene ?humanEntrez ; rdfs:label ?label ; FILTER (lang(?label) = "en") } SERVICE <http://hcls.deri.org/atag/data/gabab_example.html> { ?topic rdfs:label ?label . ?post sioc:topic ?topic }
Goal: put a relational database on the semantic web.
The Direct Mapping represents a relational database as an RDF graph.
http://someheathprovider.example/Consultation/C1
provider:C1 role:patient provider:P1 .
ISO 8601 datetimes
provider:P1 role:birthdate "1946-11-03"^^xsd:date .
ID | fname | addr |
---|---|---|
7 | Bob | 18 |
8 | Sue | NULL |
ID | city | state |
---|---|---|
18 | Cambridge | MA |
Input:
Output:
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
<Employee#fname>
vs. foaf:name
.<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city WHERE { ?who <Employee#fname> ?name . ?who <Employee#addr> ?adr . ?adr <Address#city> ?city . ?adr <Address#state> "MA" }
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city .
?adr <Address#state> "MA" }
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city .
?adr <Address#state> "MA" }
first triple produces two solutions:
?who | ?name |
---|---|
<Employee/ID-7> | "Bob" |
<Employee/ID-8> | "Sue" |
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city .
?adr <Address#state> "MA" }
second triple eliminates a solution:
?who | ?name | ?adr |
---|---|---|
<Employee/ID-7> | "Bob" | <Address/ID-18> |
<Employee/ID-8> | "Sue" |
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city .
?adr <Address#state> "MA" }
third triple binds ?city:
?who | ?name | ?adr | ?city |
---|---|---|---|
<Employee/ID-7> | "Bob" | <Address/ID-18> | "Cambridge" |
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city ;
?adr <Address#state> "MA" }
fourth triple tests a constant:
?who | ?name | ?adr | ?city |
---|---|---|---|
<Employee/ID-7> | "Bob" | <Address/ID-18> | "Cambridge" |
<Employee/ID-7> rdf:type <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> rdf:type <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" . <Address/ID-18> rdf:type <Address> . <Address/ID-18> <Address#ID> 18 . <Address/ID-18> <Address#city> "Cambridge" . <Address/ID-18> <Address#state> "MA" .
Get the name and city for
each person living in MA:
SELECT ?name ?city
WHERE { ?who <Employee#fname> ?name .
?who <Employee#addr> ?adr .
?adr <Address#city> ?city .
?adr <Address#state> "MA" }
project requested variables:
?name | ?city |
---|---|
"Bob" | "Cambridge" |
http://myco.example/allDBs/
<Employee/ID-7> a <Employee> . <Employee/ID-7> <Employee#ID> 7 . <Employee/ID-7> <Employee#fname> "Bob" . <Employee/ID-7> <Employee#addr> 18 . <Employee/ID-7> <Employee#ref-addr> <Address/ID-18> . <Employee/ID-8> a <Employee> . <Employee/ID-8> <Employee#ID> 8 . <Employee/ID-8> <Employee#fname> "Sue" .
http://myco.example/allDBs/
<Expense/ID-3> a <Expense> . <Expense/ID-3> <Expense#ID> 3 . <Expense/ID-3> <Expense#amount> 30.01 . <Expense/ID-3> <Expense#payee> 7 . <Expense/ID-3> <Expense#ref-payee> <Employee/ID-7> . <Expense/ID-4> a <Expense> . <Expense/ID-4> <Expense#ID> 4 . <Expense/ID-4> <Expense#amount> 3030.23 . <Expense/ID-4> <Expense#payee> 8 . <Expense/ID-4> <Expense#ref-payee> <Employee/ID-8> .
http://myco.example/HR/
<Employee/ID-7> <Employee#fname> "Bob" .
<Employee/ID-7> <Employee#empno> 12817 .
<Employee/ID-7> <Employee#ref-department> <Department/ID-2> .
<Department/ID-2> <Department#ID> 2 .
<Department/ID-2> <Department#name> "Engineering" .
<Department/ID-2> <Department#ref-manager> <Employee/ID-8> .
http://money.myco.example/
<expense/expno-6078> <expense#expno> 3 .
<expense/expno-6078> <expense#amount> 30.01 .
<expense/expno-6078> <expense#ref-payee> <emp/empno-2112> .
<emp/empno-2112> <emp#empno> 2112 .
<emp/empno-2112> <emp#fname> "Robert" .
<emp/empno-2112> <emp#empno> 12817 .
<emp/empno-2112> <emp#ref-addr> <Address/ID-18> .
UniProt gene
acc | val |
---|---|
P04637 | TP53 |
P04637 | P53 |
Gene Ontology association
id | symbol | dbxref_id | species_id | type_id | full_name |
---|---|---|---|---|---|
17440 | p53 | 76533 | 135847 | 25790 | p53 |
3431471 | Tp53 | 3551209 | 370755 | 25790 | tumor protein p53 |
3586773 | tp53 | 3778590 | 54765 | 25790 | tumor protein p53 |
Gene Ontology term
id | name | term_type | acc |
---|---|---|---|
2164 | transcription factor activity | molecular_function | GO:0003700 |
3814 | nucleus | cellular_component | GO:0005634 |
3814 | nucleus | cellular_component | GO:0005634 |
3906 | cytoplasm | cellular_component | GO:0005737 |
5005 | apoptosis | biological_process | GO:0006915 |
18231 | positive regulation of apoptosis | biological_process | GO:0043065 |
http://ucsc.example/uniProt/
_:a <gene#acc> "P04637"; <gene#val> "TP53". _:b <gene#acc> "P04637"; <gene#val> "P53".
http://ucsc.example/go/
@prefix goassoc: <http://ucsc.example/go/assoc#>. @prefix goassocid: <http://ucsc.example/go/assoc/id->. goassocid:17440 go:symbol "p53" ; go:dbxref_id 76533; go:species_id 135847; go:type_id 25790; go:full_name "p53". goassocid:3431471 go:symbol "Tp53"; go:dbxref_id 3551209; go:species_id 370755; go:type_id 25790; go:full_name "tumor protein p53". goassocid:3586773 go:symbol "tp53"; go:dbxref_id 3778590; go:species_id 54765; go:type_id 25790; go:full_name "tumor protein p53". @prefix goterm: <http://ucsc.example/go/term#>. @prefix gotermid: <http://ucsc.example/go/term/id->. gotermid:2164 goterm:name "transcription factor activity" ; goterm:term_type "molecular_function"; goterm:acc "GO:0003700". gotermid:3814 goterm:name "nucleus" ; goterm:term_type "cellular_component"; goterm:acc "GO:0005634". gotermid:3814 goterm:name "nucleus" ; goterm:term_type "cellular_component"; goterm:acc "GO:0005634". gotermid:3906 goterm:name "cytoplasm" ; goterm:term_type "cellular_component"; goterm:acc "GO:0005737". gotermid:5005 goterm:name "apoptosis" ; goterm:term_type "biological_process"; goterm:acc "GO:0006915". gotermid:18231 goterm:name "positive regulation of apoptosis"; goterm:term_type "biological_process"; goterm:acc "GO:0043065".
SPAAAACE LaunchSite
id | launchsite | country | place | label |
---|---|---|---|---|
1 | capecanaveral | United States | Cape Canaveral | Cape Canaveral, United States |
SPAAAACE Launch
id | name | desc | altName | inatDesign | launch | mass | name |
---|---|---|---|---|---|---|---|
1 | 1968-089A | ... | 03486 | 1968-089A | 1 | 14781.0 | Apollo 7 |
SPAAAACE Spacecraft
id | launch | date | site | vehicle | craft |
---|---|---|---|---|---|
1 | 1968-089 | 1968-10-11 | 1 | Saturn 1B | 1 |
<LaunchSite/id-93> a <LaunchSite> ; <LaunchSite#id> 93 ; <LaunchSite#labelword> "canaryislands" ; <LaunchSite#place> "Canary Islands" . _:PlaceName1 a <PlaceName> ; <PlaceName#label> "Canary Islands, Spain" ; <PlaceName#site> 93 ; <PlaceName#ref-site> <LaunchSite/id-93> .
CONSTRUCT {
?placeName rdfs:label ?label
} WHERE {
?placeName <PlaceName#label> ?label
}
.<LaunchSite/id-93> a <LaunchSite> ; <LaunchSite#id> 93 ; <LaunchSite#labelword> "canaryislands" ; <LaunchSite#place> "Canary Islands" . _:PlaceName1 a <PlaceName> ; <PlaceName#label> "Canary Islands, Spain" ; <PlaceName#site> 93 ; <PlaceName#ref-site> <LaunchSite/id-93> .
CONSTRUCT { ?s rdfs:label ?label }
WHERE {
SELECT ?label
(IRI(CONCAT("http://nasa.dataincubator.org/launchsite/", ?lw)) AS ?s)
WHERE { ?placeName <PlaceName#label> ?label .
?placeName <PlaceName#ref-site> ?site .
?site <PlaceName#labelword> ?lw }
}
.id | crewword | name |
---|---|---|
4 | harrisonhaganschmitt | Harrison Hagan Schmitt |
+
space:CrewMapping rr:tableName "Crew"; rr:subjectMap [ rr:template "http://nasa.dataincubator.org/person/{crewword}"; rr:class space:Person ] .
=
crew:harrisonhaganschmitt a foaf:Person .
id | crewword | name |
---|---|---|
4 | harrisonhaganschmitt | Harrison Hagan Schmitt |
+
space:CrewMapping rr:tableName "Crew"; rr:subjectMap [ rr:template "http://nasa.dataincubator.org/person/{crewword}"; rr:class space:Person ]; rr:predicateObjectMap [ rr:predicateMap [ rr:predicate foaf:name ]; rr:objectMap [ rr:column "name";] ] .
=
crew:harrisonhaganschmitt a foaf:Person ; foaf:name "Harrison Hagan Schmitt" .
LABELWORD | LABEL |
---|---|
canaryislands | Canary Islands, Spain |
capecanaveral | Cape Canaveral, United States |
capecanaveral | Cape Kennedy |
+
space:PlaceNameMapping a rr:TriplesMapClass; rr:sqlQuery """ SELECT LaunchSite.labelword LABELWORD, PlaceName.label LABEL FROM LaunchSite, PlaceName WHERE LaunchSite.id=PlaceName.site""" ; rr:subjectMap [ rr:template "http://nasa.dataincubator.org/launchsite/{LABELWORD}" ]; rr:predicateObjectMap [ rr:predicateMap [ rr:predicate rdfs:label ]; rr:objectMap [ rr:column "LABEL" ] ].
=
site:canaryislands rdfs:label "Canary Islands, Spain" . site:capecanaveral rdfs:label "Cape Canaveral, United States" . site:capecanaveral rdfs:label "Cape Kennedy" .
space:LaunchSiteMapping rr:tableName "LaunchSite"; rr:subjectMap [ rr:template "http://nasa.dataincubator.org/launchsite/{LABELWORD}" ]; rr:predicateObjectMap [ rr:predicate rdfs:label; rr:objectMap [ rr:parentTriplesMap space:PlaceNameMapping; rr:joinCondition [ rr:child "id"; rr:parent "site" ] ] ] .
site:canaryislands rdfs:label "Canary Islands, Spain" . site:capecanaveral rdfs:label "Cape Canaveral, United States" . site:capecanaveral rdfs:label "Cape Kennedy" .
SELECT DISTINCT 'http://purl.org/net/schemas/space/PlaceName' AS VAR_o, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' AS VAR_p, ('http://nasa.dataincubator.org/launchsite/' || PLACENAME.SITE) AS VAR_s FROM PLACENAME;
SELECT DISTINCT _go_0_gp.ID AS _go_0_gp, _go_0_gp.Symbol AS symbol, _go_0_association.ID AS _go_0_association, _go_0_association.term_id AS _go_0_t, _go_0_t.name AS label FROM gene_product AS _go_0_gp INNER JOIN association AS _go_0_association ON _go_0_association.gene_product_id=_go_0_gp.ID INNER JOIN term AS _go_0_t ON _go_0_t.ID=_go_0_association.term_id WHERE (_go_0_gp.Symbol = "tp53" OR _go_0_gp.Symbol = "p53")
Given:
SELECT ?p ?o { <http://nasa.dataincubator.org/spacecraft/1968-089A> ?p ?o }
(query)
Find me all the people in Tim Berners-Lee's FOAF file that have names and email addresses. Return each person's URI, name, and email address.
PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT * WHERE { ?person foaf:name ?name . ?person foaf:mbox ?email . }
Try it with ARQ, OpenLink's Virtuoso, or Redland's Rasqal. (Expected results.)
What URL does this database use for Apollo 7?
What is the (NASA) homepage for the mission?
Given the Talis endpoint:
PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?craft ?homepage { ?craft foaf:name "Apollo 7" . ?craft foaf:homepage ?homepage }
(query)
Find me the homepage of anyone known by Tim Berners-Lee.
PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX card: <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf#> SELECT ?homepage FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> WHERE { card:i foaf:knows ?known . ?known foaf:homepage ?homepage . }
Try it with ARQ, OpenLink's Virtuoso, or Redland's Rasqal. (Expected results.)
Given, the Talis endpoint:
PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?disc ?label { <http://nasa.dataincubator.org/spacecraft/1968-089A> space:discipline ?disc . ?disc rdfs:label ?label }
(query)
Find me 50 example concepts in the DBPedia dataset.
SELECT DISTINCT ?concept
WHERE {
?s a ?concept .
} LIMIT 50
Try it with a DBPedia-specific SPARQL endpoint. (Expected results.)
Given:
PREFIX space: <http://purl.org/net/schemas/space/> SELECT ?craft { ?craft a space:Spacecraft } LIMIT 50
(query)
Find me all landlocked countries with a population greater than 15 million.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?country_name ?population
WHERE {
?country a type:LandlockedCountries ;
rdfs:label ?country_name ;
prop:populationEstimate ?population .
FILTER (?population > 15000000) .
}
Try it with one of DBPedia's SPARQL endpoint. (Expected results.)
Given, the Talis endpoint:
PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT * { ?launch space:launched ?date FILTER ( ?date > "1968-10-1"^^xsd:date && ?date < "1968-10-30"^^xsd:date ) }
(query)
Find me all landlocked countries with a population greater than 15 million (revisited), with the highest population country first.
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?country_name ?population
WHERE {
?country a type:LandlockedCountries ;
rdfs:label ?country_name ;
prop:populationEstimate ?population .
FILTER (?population > 15000000 &&
langMatches(lang(?country_name), "EN")) .
} ORDER BY DESC(?population)
Try it with a DBPedia-specific SPARQL endpoint. (Expected results.)
Find all Jamendo artists along with their image, home page, and the location they're near.
PREFIX mo: <http://purl.org/ontology/mo/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?img ?hp ?loc WHERE { ?a a mo:MusicArtist ; foaf:name ?name ; foaf:img ?img ; foaf:homepage ?hp ; foaf:based_near ?loc . }
Try it with DBTune.org's Jamendo-specific SPARQL endpoint. Be sure to choose SPARQL rather than SeRQL. (Expected results.)
Find all Jamendo artists along with their image, home page, and the location they're near, if any.
PREFIX mo: <http://purl.org/ontology/mo/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?img ?hp ?loc WHERE { ?a a mo:MusicArtist ; foaf:name ?name . OPTIONAL { ?a foaf:img ?img } OPTIONAL { ?a foaf:homepage ?hp } OPTIONAL { ?a foaf:based_near ?loc } }
Try it with DBTune.org's Jamendo-specific SPARQL endpoint. Be sure to choose SPARQL rather than SeRQL. (Expected results.)
Find me the cellular processes that are either integral to or a refinement of signal transduction.
PREFIX go: <http://purl.org/obo/owl/GO#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX obo: <http://www.obofoundry.org/ro/ro.owl#>
SELECT DISTINCT ?label ?process
WHERE {
{ ?process obo:part_of go:GO_0007165 } # integral to
UNION
{ ?process rdfs:subClassOf go:GO_0007165 } # refinement of
?process rdfs:label ?label
}
Try it with the neurocommons SPARQL endpoint. (Expected results.)
Find me people who have been involved with at least three ISWC or ESWC conference events.
SELECT DISTINCT ?name WHERE { ?person foaf:name ?name . GRAPH ?g1 { ?person a foaf:Person } GRAPH ?g2 { ?person a foaf:Person } GRAPH ?g3 { ?person a foaf:Person } FILTER(?g1 != ?g2 && ?g1 != ?g3 && ?g2 != ?g3) . }
Try it with the data.semanticweb.org SPARQL endpoint. (Expected results.)
Convert FOAF data to VCard data.
PREFIX vCard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT {
?X vCard:FN ?name .
?X vCard:URL ?url .
?X vCard:TITLE ?title .
}FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
WHERE {
OPTIONAL { ?X foaf:name ?name . FILTER isLiteral(?name) . }
OPTIONAL { ?X foaf:homepage ?url . FILTER isURI(?url) . }
OPTIONAL { ?X foaf:title ?title . FILTER isLiteral(?title) . }
}
Try it with ARQ or OpenLink's Virtuoso. (Expected results.)
Is the Amazon river longer than the Nile River?
PREFIX prop: <http://dbpedia.org/property/>
ASK
{
<http://dbpedia.org/resource/Amazon_River> prop:length ?amazon .
<http://dbpedia.org/resource/Nile> prop:length ?nile .
FILTER(?amazon > ?nile) .
}
Try it with the Virtuoso DBPedia SPARQL endpoint. (Expected results. - or are they??)
Tell me whatever you'd like to tell me about the Ford Motor Company.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DESCRIBE ?ford WHERE {
?ford foaf:name "FORD MOTOR CO" .
}
Note: The EDGAR-specific SPARQL endpoint is not currently up. (Expected results.)
A new SPARQL WG was chartered in March 2009 to extend the SPARQL language and landscape. SPARQL 1.1 Query includes these extensions:
How many neutrons does the most common isotope of each element have?
PREFIX : <http://www.daml.org/2003/01/periodictable/PeriodicTable#>
SELECT ?element ?protons
(ROUND(?weight) - ?protons AS ?neutrons)
FROM <http://www.daml.org/2003/01/periodictable/PeriodicTable.owl>
WHERE {
[] a :Element ;
:atomicNumber ?protons ;
:atomicWeight ?weight ;
:name ?element .
} ORDER BY ?protons
Try it with sparql.org. (Expected results.)
How many roads of each classification are there in the UK?
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX roads: <http://transport.data.gov.uk/def/traffic/> SELECT ?cat (COUNT(DISTINCT ?thing) AS ?roads) WHERE { ?thing a roads:Road ; roads:countPointRoadCategory ?cat . } GROUP BY ?cat
Try it with the data.gov.uk endpoint. Make sure to choose the Transport dataset. (Expected results.)
Retrieve the second page of names and emails of people in Tim Berners-Lee's FOAF file, given that each page has 10 people.
PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?email FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> WHERE { ?person foaf:name ?name . OPTIONAL { ?person foaf:mbox ?email } } ORDER BY ?name LIMIT 10 OFFSET 10
Retrieve the second page of names and emails of people in Tim Berners-Lee's FOAF file, given that each page has 10 people.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?email
FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
WHERE {
{ SELECT DISTINCT ?person ?name WHERE {
?person foaf:name ?name
} ORDER BY ?name LIMIT 10 OFFSET 10 }
OPTIONAL { ?person foaf:mbox ?email }
}
Find the person entries in Tim Berners-Lee's FOAF file that do not contain a URL for the person's FOAF file.
PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> WHERE { ?person a foaf:Person ; foaf:name ?name . OPTIONAL { ?person rdfs:seeAlso ?url } FILTER(!bound(?url)) }
Find the person entries in Tim Berners-Lee's FOAF file that do not contain a URL for the person's FOAF file.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?name
FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
WHERE {
?person a foaf:Person ; foaf:name ?name .
MINUS { ?person rdfs:seeAlso ?url }
}
Find the person entries in Tim Berners-Lee's FOAF file that do not contain a URL for the person's FOAF file.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?name
FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf>
WHERE {
?person a foaf:Person ; foaf:name ?name .
FILTER(NOT EXISTS { ?person rdfs:seeAlso ?url })
}
Find all of the beers included in the beer ontology.
PREFIX beer: <http://www.w3.org/2011/12/beer.owl#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?beer FROM <http://www.w3.org/2011/12/beer.owl> WHERE { ?beer rdf:type beer:Beer . }
Find all of the beers included in the beer ontology.
PREFIX beer: <http://www.w3.org/2011/12/beer.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?beer
FROM <http://www.w3.org/2011/12/beer.owl>
WHERE {
?beer
rdf:type/rdfs:subClassOf* beer:Beer .
}
Find the birth dates of all of the actors in Star Trek: The Motion Picture
PREFIX movie: <http://data.linkedmdb.org/resource/movie/> PREFIX dbpedia: <http://dbpedia.org/ontology/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?actor_name ?birth_date FROM <http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf> # placeholder graph WHERE { SERVICE <http://data.linkedmdb.org/sparql> { <http://data.linkedmdb.org/resource/film/675> movie:actor ?actor . ?actor movie:actor_name ?actor_name } SERVICE <http://dbpedia.org/sparql> { ?actor2 a dbpedia:Actor ; foaf:name ?actor_name_en ; dbpedia:birthDate ?birth_date . FILTER(STR(?actor_name_en) = ?actor_name) } }
DROP GRAPH u; CREATE GRAPH u; INSERT DATA { GRAPH u { ... RDF payload ... } }
DROP GRAPH u
INSERT DATA { GRAPH u { ... RDF payload ... } }
CONSTRUCT { ?s ?p ?o } WHERE { GRAPH u { ?s ?p ?o } }