Wikidata:WikiProject University degrees/Queries

Home

 

Items & Properties

 

Reports

 

Queries

 

Discussions

 

SPARQL queries :

What degree-granting universities does a country have in which cities?

edit

Either the university is an institution of higher education or it is a subclass of that, and is in a city that is located in a country, in this case, Germany. And the institution (probably) still exists.

The following query uses these:

Extend query with exact coordinates shown in a map using Portugal as example:

The following query uses these:

Features: map (Q24515275)     

#Locations of universities in Portugal
#added before 2016-10
#defaultView:Map
SELECT ?universityLabel ?universityDescription ?website ?coord WHERE {
  ?university (wdt:P31/wdt:P279*) wd:Q3918.
  ?university wdt:P17 wd:Q45.
  ?university wdt:P625 ?coord.
  OPTIONAL { ?university wdt:P856 ?website. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de". }
}

What currently existing universities are located in a specific city?

edit

The following query uses these:

Instead of university (Q3918) use higher education institution (Q38723)! Exclude universities that have an end data or a following institution.

What degree-granting universities does a city have?

edit

Start off with collecting up the existing universities of a city, then see if any of them offer degrees. We will only get those that are actually entered into Wikidata, so there are currently not many.

The following query uses these:

What degrees does a university offer?

edit

The following query uses these:

  • Properties: grants (P5460)     , academic major (P812)     
    SELECT ?degreeLabel ?majorLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
      wd:Q875138 p:P5460 ?statement . # HTW Berlin
      ?statement ps:P5460 ?degree .
      ?statement pq:P812 ?major .
      
      }
    ORDER BY ?degreeLabel
    

Which university/ies offers a specific degree in a specific major?

edit

The university is an instance of university and offers a given degree (in the example a master's degree) in a specific major (in the example - Electrical Engineering)

The following query uses these:

  • Properties: instance of (P31)     , grants (P5460)     , academic major (P812)     
    SELECT DISTINCT ?university ?universityLabel ?degreeLabel ?majorLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
      ?university wdt:P31 wd:Q3918  .
      ?university wdt:P5460 ?degree .
    OPTIONAL { ?university p:P5460 ?acadDegree . ?acadDegree pq:P812 ?major}
     
    FILTER(?degree = wd:Q183816) #master's degree
    FILTER(?major = wd:Q55636433) #Electrical Engineering 
    }
    
    ORDER BY ?universityLabel ?degreeLabel ?majorLabel
    

People with a bachelor's degree in astronomy

edit

There are different ways of modelling an academic major.

This one models: Q educated at University and the "educated at" has both qualifiers academic degree = bachelor or subclass thereof and academic major = astronomy (to keep the lists small...)

The following query uses these:

  • Properties: instance of (P31)     , coordinate location (P625)     , subclass of (P279)     , educated at (P69)     , academic degree (P512)     , academic major (P812)     
    # List of persons who hold a bachelor's degree in Astronomy
    SELECT DISTINCT ?institution ?institutionLabel ?person ?personLabel ?degree ?degreeLabel ?majorLabel WHERE {
      ?person wdt:P31 wd:Q5 ; # instances (P31) of humans (Q5)
                p:P69 ?statement . # check for an "educated at" (P69) statement
      
      ?statement ps:P69 ?institution . # get value of the "educated at" statement, i.e. the institution
      ?institution wdt:P625 ?geoloc . # get the geolocation of the institution
    
      ?statement pq:P512 ?degree . # get qualifier "academic degree" (P512) 
      ?statement pq:P812 ?major . # get qualifier "academic major (P812)
      ?degree wdt:P31*/wdt:P279* wd:Q163727 . # filter for bachelor degrees (Q163727) 
      ?major wdt:P31*/wdt:P279* wd:Q333 . # filter major for astronomy (Q333)
      
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    

Astronomy is too small for the other queries I want to ask. So I tried Computer Science (Q21198) and get some bizarre results. There also appear to be no persons with a sub-qualifier of academic major.

People with a bachelor's degree in computer science

edit

But when I try "computer science", I get Latin American studies, too:

The following query uses these:

  • Properties: instance of (P31)     , coordinate location (P625)     , subclass of (P279)     , educated at (P69)     , academic degree (P512)     , academic major (P812)     
    # List of persons who hold a bachelor's degree in Computer science
    SELECT DISTINCT ?institution ?institutionLabel ?person ?personLabel ?degree ?degreeLabel ?majorLabel WHERE {
      ?person wdt:P31 wd:Q5 ; # instances (P31) of humans (Q5)
                p:P69 ?statement . # check for an "educated at" (P69) statement
      
      ?statement ps:P69 ?institution . # get value of the "educated at" statement, i.e. the institution
      ?institution wdt:P625 ?geoloc . # get the geolocation of the institution
    
      ?statement pq:P512 ?degree . # get qualifier "academic degree" (P512) 
      ?statement pq:P812 ?major . # get qualifier "academic major (P812)
      ?degree wdt:P31*/wdt:P279* wd:Q163727 . # filter for bachelor degrees (Q163727) 
      ?major wdt:P31*/wdt:P279* wd:Q21198 . # filter major for computer science (Q21198)
      
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }
    

How many members of the Bundestag have a university degree?

edit

How could we potentially ask this question in SPARQL? Turns out, most of them don't have educational data stored in Wikidata. You have to pick each little bit of information out of the Wikipedia pages.

The following query uses these:

  • Properties: coordinate location (P625)     , instance of (P31)     , subclass of (P279)     , position held (P39)     , educated at (P69)     , elected in (P2715)     , academic degree (P512)     
    # German members of the German Bundestag with a doctorate university degree
    # 
    SELECT ?politician ?politician_label ?institution ?institutionLabel ?degreeLabel
    WHERE
    {
        ?politician p:P39 # find items that have the position 
                    [ps:P39 wd:Q1939555 ;      # of member of German Bundestag
                     pq:P2715 wd:Q15062956 ] . # and a qualifier "elected in the 2017 German federal election"
                                    
        ?politician p:P69 ?educatedAt .      # has an "educated at" statement 
        ?educatedAt ps:P69 ?institution .    # get value of the "educated at" statement, i.e. the institution
        ?institution wdt:P625 ?geoloc .     # get the geolocation of the institution just for fun
      
        OPTIONAL {?educatedAt pq:P512 ?degree }        # get qualifier "academic degree" (P512) 
    #    ?degree wdt:P31*/wdt:P279* wd:Q849697 . # filter for doctoral degrees
    	 
     		 
    	OPTIONAL {?politician rdfs:label ?politician_label filter (lang(?politician_label) = "en") .}
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    
    }
    ORDER BY ASC (?politician)