Sparql queries - RooyyDoe/functional-programming GitHub Wiki

SPARQL data queries

I had to make multiple queries to get the exact data that I needed for my concept. My idea was to clean the query data in javascript and add the results all back together so I could use it for the D3 library. I tried to get it all into one query with SparQL, but after a while Ivo told me it is not possible to get the exact data that I need.

The first query I made was the one where I asked for all the continents that are available in the database. When this query runs it will show every continent that is available in the collection database. In javascript I want to clean this up to get only the five continents that I explained in my concept because most of the objects are distributed over these continents.

Schermafdruk 2019-11-08 11 09 13

SELECT ?continent  WHERE {
  <https://hdl.handle.net/20.500.11840/termmaster2> skos:narrower ?continent .
}

After this query I needed to get all the main categories that are available in the database. For this I used the thesaurus Functionele Category and got all the narrower tags of this.

Schermafdruk 2019-11-08 11 18 12

SELECT ?categoryName ?mainCategory  WHERE {
  <https://hdl.handle.net/20.500.11840/termmaster2802> skos:narrower ?mainCategory .
  ?mainCategory skos:prefLabel ?categoryName .
}

For my concept I need to get a count of all the objects that are linked to the continent and in that continent to the main category. At first this wasn't possible because you can't count up every sub-sub or sub category to the main category in SparQL. But what worked out for me was getting the objects of all main categories and sub and sub-sub categories.

Schermafdruk 2019-11-08 11 26 15

SELECT ?categoryName (COUNT(?category) AS ?categoryAmount) WHERE {
  
       <https://hdl.handle.net/20.500.11840/termmaster3> skos:narrower* ?continent .
  	   ?obj dct:spatial ?continent .
  
  	   <https://hdl.handle.net/20.500.11840/termmaster2803> skos:narrower* ?category .
       ?obj edm:isRelatedTo ?category .
  	   ?category skos:prefLabel ?categoryName .
  	   
} GROUP BY ?categoryName


In the query above I made it so that I only get one main category and all the sub categories of this collection (jacht, visserij, voedselgaring). In javascript I want to use template literals and loops to get all the categories and link them to the continents. This will be further explained in the subject Functional Data Cleaning

⚠️ **GitHub.com Fallback** ⚠️