Project:SPARQL/examples: Difference between revisions

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


=== 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) ===  
=== 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) ===  
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 55: Line 56:
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>


SELECT ?item ?itemLabelNL ?itemLabelEN  
SELECT DISTINCT ?item ?itemLabelNL ?itemLabelEN  
?itemDescriptionNL ?itemDescriptionEN  
?itemDescriptionNL ?itemDescriptionEN  
(GROUP_CONCAT(DISTINCT ?itemAliasNL ; separator = "|") as ?itemAliasesNL )
(GROUP_CONCAT(DISTINCT ?itemAliasNL ; separator = "|") as ?itemAliasesNL )
Line 136: Line 137:


<sparql tryit="1">
<sparql tryit="1">
# mixing data from this Wikibase with data from Wikidata
# 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#>


PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?item ?itemLabel ?itemDescription
PREFIX schema: <http://schema.org/>
?wikidataEquivalentURI
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
?wdImage #P18 image from Wikidata
PREFIX wikibase: <http://wikiba.se/ontology#>
?wdWorksInCollection ?wdWorksInCollectionLabelNL
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
 
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>


SELECT ?p ?pType
=== Federated querying: mixing data from this Wikibase with data from the NTA in data.bibliotheken.nl (via the PPN) -- TODO!!!!!!!!! ===  
?pLabelNL ?pLabelEN
?pDescriptionNL ?pDescriptionEN
(GROUP_CONCAT(DISTINCT ?pAliasNL ; separator = "|") as ?pAliasesNL )
(GROUP_CONCAT(DISTINCT ?pAliasEN ; separator = "|") as ?pAliasesEN )
?wikidataEquivalentProperty


WHERE {
<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#>


  ?p wikibase:propertyType ?pType .
SELECT DISTINCT ?item ?itemLabel ?itemDescription
  OPTIONAL{?p wdt:P1 ?wikidataEquivalentProperty.}
?wikidataEquivalentURI
?wdImage #P18 image from Wikidata
?wdWorksInCollection ?wdWorksInCollectionLabelNL


   OPTIONAL{?p rdfs:label ?pLabelNL FILTER(LANG(?pLabelNL)='nl').}
WHERE
   OPTIONAL{?p rdfs:label ?pLabelEN FILTER(LANG(?pLabelEN)='en').}
{
    
   VALUES ?item {kbwd:Q10 kbwd:Q29} # Louis Auguste Gustave Doré + Theun de Vries
   OPTIONAL{?p schema:description ?pDescriptionNL FILTER(LANG(?pDescriptionNL) = "nl"). }
   ?item kbwdt:P1 ?wikidataEquivalentURI.
   OPTIONAL{?p schema:description ?pDescriptionEN FILTER(LANG(?pDescriptionEN) = "en"). }
  #Retrieve some data from data.bibliotheken.nl
 
   SERVICE <https://query.wikidata.org/sparql>{
  OPTIONAL{?p skos:altLabel ?pAliasNL FILTER(LANG(?pAliasNL) = "nl"). }   
   OPTIONAL {?wikidataEquivalentURI wdt:P18 ?wdImage.}
   OPTIONAL{?p skos:altLabel ?pAliasEN FILTER(LANG(?pAliasEN) = "en"). }    
   OPTIONAL {?wikidataEquivalentURI wdt:P6379 ?wdWorksInCollection.
   
          ?wdWorksInCollection rdfs:label ?wdWorksInCollectionLabelNL.
          FILTER(LANG(?wdWorksInCollectionLabelNL) = "nl").}   
}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],nl". }  
}
}
GROUP BY ?p ?pType ?pLabelNL ?pLabelEN ?pDescriptionNL ?pDescriptionEN ?wikidataEquivalentProperty
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
ORDER BY ASC(xsd:integer(STRAFTER(STR(?p), 'P')))
</sparql>
</sparql>
emailconfirmed
952

edits

Navigation menu