query-5de62caa3194eb42bed07e2c6c0ef0ed
Chemical compounds and elements
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>
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
?compound ?compoundLabel
(CONCAT("#compound/", SUBSTR(STR(?wikidata), 32)) AS ?compoundUrl)
?compoundDescription
?wikidata
(CONCAT(SUBSTR(STR(?wikidata), 32), " ↗") AS ?wikidataLabel)
(CONCAT("https://www.wikidata.org/wiki/", SUBSTR(STR(?wikidata), 32)) AS ?wikidataUrl)
("Scholia ↗" AS ?scholia)
(CONCAT("https://scholia.toolforge.org/chemical/", SUBSTR(STR(?wikidata), 32)) AS ?scholiaUrl)
(?compound AS ?wikifcd)
("WikiFCD ↗" as ?wikifcdLabel)
(CONCAT("https://wikifcd.wikibase.cloud/wiki/Item:", SUBSTR(STR(?compound), 39)) AS ?wikifcdUrl)
WHERE {
{ ?compound wbt:P1 wb:Q567677 }
UNION
{ ?compound wbt:P1 wb:Q567670 }
OPTIONAL { ?compound wbt:P61 ?wikidata }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?compound"):::projected
v3("?compoundUrl")
v6("?scholia")
v7("?scholiaUrl")
v2("?wikidata"):::projected
v4("?wikidataLabel")
v5("?wikidataUrl")
v8("?wikifcd")
v9("?wikifcdLabel")
v10("?wikifcdUrl")
c3([https://wikifcd.wikibase.cloud/entity/Q567670]):::iri
c6(["bd:serviceParam"]):::iri
c2([https://wikifcd.wikibase.cloud/entity/Q567677]):::iri
c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --https://wikifcd.wikibase.cloud/prop/direct/P1--> c3
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --https://wikifcd.wikibase.cloud/prop/direct/P1--> c2
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -.https://wikifcd.wikibase.cloud/prop/direct/P61.-> v2
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c6 --"wikibase:language"--> c8
end
bind0[/"concat('#compound/',substring(str(?wikidata),'32^^xsd:integer'))"/]
v2 --o bind0
bind0 --as--o v3
bind1[/"concat(substring(str(?wikidata),'32^^xsd:integer'),' ↗')"/]
v2 --o bind1
bind1 --as--o v4
bind2[/"concat('https://www.wikidata.org/wiki/',substring(str(?wikidata),'32^^xsd:integer'))"/]
v2 --o bind2
bind2 --as--o v5
bind3[/"'Scholia ↗'"/]
bind3 --as--o v6
bind4[/"concat('https://scholia.toolforge.org/chemical/',substring(str(?wikidata),'32^^xsd:integer'))"/]
v2 --o bind4
bind4 --as--o v7
bind5[/"?compound"/]
v1 --o bind5
bind5 --as--o v8
bind6[/"'WikiFCD ↗'"/]
bind6 --as--o v9
bind7[/"concat('https://wikifcd.wikibase.cloud/wiki/Item:',substring(str(?compound),'39^^xsd:integer'))"/]
v1 --o bind7
bind7 --as--o v10