Project:SPARQL/examples: Difference between revisions
Jump to navigation
Jump to search
(→Food Composition Tables in WikiFCD: add timeline fct with pub date query) |
(→Food Composition Tables in WikiFCD: update heading) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
} | } | ||
</SPARQL> | </SPARQL> | ||
==Food Items with SMILING Thailand Food Code and Reference== | |||
<SPARQL> | |||
PREFIX wd: <http://www.wikidata.org/entity/> | |||
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/> | |||
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/> | |||
PREFIX p: <https://wikifcd.wikibase.cloud/prop/> | |||
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/> | |||
PREFIX prov: <http://www.w3.org/ns/prov#> | |||
SELECT ?food ?foodLabel ?code WHERE { | |||
?food wbt:P315 ?code; | |||
p:P315 [ prov:wasDerivedFrom [pr:P62 wb:Q568274]]. | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | |||
} | |||
</SPARQL> | |||
==Timeline View of FCTs with Publication Dates== | ==Timeline View of FCTs with Publication Dates== | ||
<SPARQL> | <SPARQL> | ||
Line 112: | Line 129: | ||
}} | }} | ||
Limit 100 | Limit 100 | ||
</SPARQL> | |||
==Federated Query WikiFCD PFaF with Optional Image== | |||
<SPARQL> | |||
PREFIX wdt: <http://www.wikidata.org/prop/direct/> | |||
PREFIX wd: <http://www.wikidata.org/entity/> | |||
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/> | |||
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/> | |||
SELECT DISTINCT ?food ?foodLabel ?taxon ?value (SAMPLE (?img) AS ?image) | |||
WHERE { | |||
?food wbt:P73 ?taxon. | |||
?taxon wbt:P61 ?wikidata. | |||
?food rdfs:label ?foodLabel . | |||
SERVICE <https://query.wikidata.org/sparql> { | |||
?wikidata wdt:P4301 ?value. | |||
OPTIONAL {?wikidata wdt:P18 ?img.} | |||
}} | |||
GROUP BY ?food ?foodLabel ?taxon ?value | |||
</SPARQL> | |||
==Food Items with SMILING Cambodia Food Code and Reference== | |||
<SPARQL> | |||
PREFIX wd: <http://www.wikidata.org/entity/> | |||
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/> | |||
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/> | |||
PREFIX p: <https://wikifcd.wikibase.cloud/prop/> | |||
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/> | |||
PREFIX prov: <http://www.w3.org/ns/prov#> | |||
SELECT ?food ?foodLabel ?code WHERE { | |||
?food wbt:P313 ?code; | |||
p:P313 [ prov:wasDerivedFrom [pr:P62 wb:Q128052]]. | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | |||
} | |||
</SPARQL> | |||
==Ranked List of Food Items Containing Most to Least DHA (Docosahexaenoic acid)== | |||
<SPARQL> | |||
PREFIX wd: <http://www.wikidata.org/entity/> | |||
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/> | |||
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/> | |||
PREFIX p: <https://wikifcd.wikibase.cloud/prop/> | |||
PREFIX psv: <https://wikifcd.wikibase.cloud/prop/statement/value/> | |||
SELECT ?itemLabel ?_DHA ?unitLabel WHERE { | |||
?item p:P135/psv:P135 ?DHA. | |||
?DHA wikibase:quantityAmount ?_DHA. | |||
?DHA wikibase:quantityUnit ?unit. | |||
{ SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"} }} | |||
ORDER BY DESC(?_DHA) | |||
</SPARQL> | </SPARQL> |
Latest revision as of 13:05, 1 February 2024
Food Composition Tables in WikiFCD
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?item ?itemLabel WHERE {
?item wbt:P1 wb:Q12.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Food Items with SMILING Thailand Food Code and Reference
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?food ?foodLabel ?code WHERE {
?food wbt:P315 ?code;
p:P315 [ prov:wasDerivedFrom [pr:P62 wb:Q568274]].
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Timeline View of FCTs with Publication Dates
#defaultView:Timeline
#Food Composition Tables in WikiFCD with publication dates
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT ?item ?itemLabel ?date WHERE {
?item wbt:P1 wb:Q12.
?item wbt:P58 ?date.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
WikiFCD federated query for food items with foodOn id and NALT id
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT DISTINCT ?item ?itemLabel ?foodon ?nalt WHERE {
?food wbt:P73 ?item.
?item wbt:P1 wb:Q20.
?food wbt:P309 ?foodon.
?item wbt:P61 ?wikidata.
?item rdfs:label ?itemLabel
SERVICE <https://query.wikidata.org/sparql> {
?wikidata wdt:P2004 ?nalt
}}
WikiFCD food items with FoodOn identifier
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
SELECT DISTINCT ?food ?foodLabel ?foodon WHERE {
?food wbt:P309 ?foodon;
rdfs:label ?foodLabel.
}
WikiFCD Count of Properties by Property Type
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
SELECT (COUNT(?property) as ?pcount ) ?wbtype WHERE {
?property rdf:type wikibase:Property.
?property wikibase:propertyType ?wbtype.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?wbtype
ORDER BY DESC(?pcount)
Graph Visualization of Food Items with Stated Taxon Source Referenced to a FCT
#defaultView:Graph
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
SELECT ?item ?itemLabel ?taxon ("00FFFF" AS ?rgb) ?taxonLabel WHERE {
?item wbt:P73 ?taxon;
p:P73 [prov:wasDerivedFrom [pr:P62 ?source ]].
?source wbt:P1 wb:Q12.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Federated Query WikiFCD Taxon Name is Main Subject of a Scientific Article
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
SELECT DISTINCT ?item ?itemLabel ?wikidata ?article ?articleLabel WHERE {
?item wbt:P1 wb:Q20.
?item wbt:P61 ?wikidata.
?item rdfs:label ?itemLabel .
SERVICE <https://query.wikidata.org/sparql> {
?article wdt:P921 ?wikidata.
?article rdfs:label ?articleLabel.
}}
Limit 100
Federated Query WikiFCD PFaF with Optional Image
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
SELECT DISTINCT ?food ?foodLabel ?taxon ?value (SAMPLE (?img) AS ?image)
WHERE {
?food wbt:P73 ?taxon.
?taxon wbt:P61 ?wikidata.
?food rdfs:label ?foodLabel .
SERVICE <https://query.wikidata.org/sparql> {
?wikidata wdt:P4301 ?value.
OPTIONAL {?wikidata wdt:P18 ?img.}
}}
GROUP BY ?food ?foodLabel ?taxon ?value
Food Items with SMILING Cambodia Food Code and Reference
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX pr: <https://wikifcd.wikibase.cloud/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT ?food ?foodLabel ?code WHERE {
?food wbt:P313 ?code;
p:P313 [ prov:wasDerivedFrom [pr:P62 wb:Q128052]].
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Ranked List of Food Items Containing Most to Least DHA (Docosahexaenoic acid)
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wbt: <https://wikifcd.wikibase.cloud/prop/direct/>
PREFIX wb: <https://wikifcd.wikibase.cloud/entity/>
PREFIX p: <https://wikifcd.wikibase.cloud/prop/>
PREFIX psv: <https://wikifcd.wikibase.cloud/prop/statement/value/>
SELECT ?itemLabel ?_DHA ?unitLabel WHERE {
?item p:P135/psv:P135 ?DHA.
?DHA wikibase:quantityAmount ?_DHA.
?DHA wikibase:quantityUnit ?unit.
{ SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en"} }}
ORDER BY DESC(?_DHA)