Project:SPARQL/examples: Difference between revisions

Jump to navigation Jump to search
No edit summary
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Examples==
==Voorbeelden==
<big>''De queries op deze pagina worden in de Voorbeelden-dropdown op https://kbtestwikibase.wikibase.cloud/query/ weergegeven.''</big>


=== Overview of properties in this Wikibase, with their Labels, Descriptions and Aliases, both in NL and in EN, as well their equivalent properties in Wikidata (if applicable) ===  
=== Overview of properties (Ps) in this Wikibase, with their Labels, Descriptions and Aliases, both in NL and in EN, as well their equivalent properties in Wikidata (if applicable) ===  


<sparql tryit="1">
<sparql tryit="1">
Line 15: Line 16:
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>


SELECT ?p ?pType  
SELECT DISTINCT ?p ?pType  
?pLabelNL ?pLabelEN  
?pLabelNL ?pLabelEN  
?pDescriptionNL ?pDescriptionEN  
?pDescriptionNL ?pDescriptionEN  
Line 41: Line 42:
</sparql>
</sparql>


=== Alle Qs in deze Wikibase===
=== Overview of items (Qs) in this Wikibase, with their Labels, Descriptions and Aliases, both in NL and in EN, as well their equivalent Q-items en URIs in Wikidata (if applicable) ===


<sparql tryit="1">
<sparql tryit="1">
# All Qnumbers in this Wikibase
# Overview of items (Qs) in this Wikibase,
# with their Labels, Descriptions and Aliases,
# both in NL and in EN,
# as well their equivalent Q-items en URIs in Wikidata (if applicable)
 
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?identifier ?identifierLabel ?identifierDescription ?identifierAltLabel
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
 
SELECT DISTINCT ?item ?itemLabelNL ?itemLabelEN
?itemDescriptionNL ?itemDescriptionEN
(GROUP_CONCAT(DISTINCT ?itemAliasNL ; separator = "|") as ?itemAliasesNL )
(GROUP_CONCAT(DISTINCT ?itemAliasEN ; separator = "|") as ?itemAliasesEN )
?wikidataEquivalentURI ?wikidataEquivalentItem
 
WHERE  
WHERE  
{
{
    ?identifier wikibase:identifiers ?b
  ?item wikibase:identifiers ?b
   SERVICE wikibase:label { bd:serviceParam wikibase:language "nl". }
   OPTIONAL{?item wdt:P1 ?wikidataEquivalentURI.}
  OPTIONAL{?item wdt:P4 ?wikidataEquivalentItem.}
 
  OPTIONAL{?item rdfs:label ?itemLabelNL FILTER(LANG(?itemLabelNL)='nl').}
  OPTIONAL{?item rdfs:label ?itemLabelEN FILTER(LANG(?itemLabelEN)='en').}
 
  OPTIONAL{?item schema:description ?itemDescriptionNL FILTER(LANG(?itemDescriptionNL) = "nl"). } 
  OPTIONAL{?item schema:description ?itemDescriptionEN FILTER(LANG(?itemDescriptionEN) = "en"). }
 
  OPTIONAL{?item skos:altLabel ?itemAliasNL FILTER(LANG(?itemAliasNL) = "nl"). } 
  OPTIONAL{?item skos:altLabel ?itemAliasEN FILTER(LANG(?itemAliasEN) = "en"). }    
   
}
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?identifier), 'Q')))
GROUP BY ?item ?itemLabelNL ?itemLabelEN ?itemDescriptionNL ?itemDescriptionEN ?wikidataEquivalentURI ?wikidataEquivalentItem 
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
</sparql>
</sparql>


Line 90: Line 117:
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
LIMIT 35
LIMIT 35
</sparql>
===Dingen die een instantie (P3) zijn van andere dingen===
<sparql tryit="1">
# Dingen die een instantie (P3) zijn van andere dingen
PREFIX wd: <https://kbtestwikibase.wikibase.cloud/entity/>
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?ding ?dingLabel ?dingDescription  ?IsEen ?IsEenLabel ?IsEenDescription WHERE
{
?ding wdt:P3 ?IsEen
  SERVICE wikibase:label { bd:serviceParam wikibase:language "nl". }
}
</sparql>
=== Federated querying: mixing data from this Wikibase with data from Wikidata ===
<sparql tryit="1">
# Federated querying: mixing data from this Wikibase with data from Wikidata
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX kbwdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX kbwd: <https://kbtestwikibase.wikibase.cloud/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?item ?itemLabel ?itemDescription
?wikidataEquivalentURI
?wdImage #P18 image from Wikidata
?wdWorksInCollection ?wdWorksInCollectionLabelNL
WHERE
{
  VALUES ?item {kbwd:Q10 kbwd:Q29} # Louis Auguste Gustave Doré + Theun de Vries
  ?item kbwdt:P1 ?wikidataEquivalentURI.
  #Retrieve some data from Wikidata
  SERVICE <https://query.wikidata.org/sparql>{
  OPTIONAL {?wikidataEquivalentURI wdt:P18 ?wdImage.}
  OPTIONAL {?wikidataEquivalentURI wdt:P6379 ?wdWorksInCollection.
          ?wdWorksInCollection rdfs:label ?wdWorksInCollectionLabelNL.
          FILTER(LANG(?wdWorksInCollectionLabelNL) = "nl").} 
}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl". }
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
</sparql>
=== Federated querying: mixing data from this Wikibase with data from the NTA in data.bibliotheken.nl (via the PPN) -- TODO!!!!!!!!! ===
<sparql tryit="1">
# Federated querying: mixing data from this Wikibase with data from the NTA in data.bibliotheken.nl (via the PPN)
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX kbwdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX kbwd: <https://kbtestwikibase.wikibase.cloud/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?item ?itemLabel ?itemDescription
?wikidataEquivalentURI
?wdImage #P18 image from Wikidata
?wdWorksInCollection ?wdWorksInCollectionLabelNL
WHERE
{
  VALUES ?item {kbwd:Q10 kbwd:Q29} # Louis Auguste Gustave Doré + Theun de Vries
  ?item kbwdt:P1 ?wikidataEquivalentURI.
  #Retrieve some data from data.bibliotheken.nl
  SERVICE <https://query.wikidata.org/sparql>{
  OPTIONAL {?wikidataEquivalentURI wdt:P18 ?wdImage.}
  OPTIONAL {?wikidataEquivalentURI wdt:P6379 ?wdWorksInCollection.
          ?wdWorksInCollection rdfs:label ?wdWorksInCollectionLabelNL.
          FILTER(LANG(?wdWorksInCollectionLabelNL) = "nl").} 
}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl". }
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
</sparql>
</sparql>
emailconfirmed
952

edits

Navigation menu