Skip to content

Instantly share code, notes, and snippets.

@alexbilbie
Created April 24, 2012 01:04
Show Gist options
  • Save alexbilbie/2475211 to your computer and use it in GitHub Desktop.
Save alexbilbie/2475211 to your computer and use it in GitHub Desktop.
University of Lincoln SPARQL queries

University of Lincoln SPARQL Queries

Organisation

Get all divisions

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT DISTINCT ?dept ?deptName
WHERE {
  ?dept a org:OrganizationalUnit .
  ?dept rdfs:label ?deptName .
  ?dept org:unitOf <http://lincoln.ac.uk/> .
}

Get all departments in $DIVISION$

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT DISTINCT ?dept ?deptName
WHERE {
  ?dept a org:OrganizationalUnit .
  ?dept rdfs:label ?deptName .
  ?dept org:unitOf <http://id.online.lincoln.ac.uk/division/$DIVISION$> .
}

Get all staff in $DIVISION$

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT  ?givenName ?familyName
WHERE {
  ?person a foaf:Person .
  ?person org:memberOf <http://id.online.lincoln.ac.uk/division/$DIVISION$> .
  ?person org:memberOf ?division .
  ?division a org:OrganizationalUnit .
  ?division org:unitOf ?parent .
  ?person foaf:givenName ?givenName .
  ?person foaf:familyName ?familyName .
  FILTER (?parent = "http://lincoln.ac.uk/")
}

Get all staff in $DEPARTMENT$

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT ?givenName ?familyName
WHERE {
  ?person a foaf:Person .
  ?person org:memberOf <http://id.online.lincoln.ac.uk/department/$DEPARTMENT$> .
  ?person org:memberOf ?division .
  ?division a org:OrganizationalUnit .
  ?division org:unitOf ?parent .
  ?person foaf:givenName ?givenName .
  ?person foaf:familyName ?familyName .
  FILTER (?parent != "http://lincoln.ac.uk/")
}

Get the division that a member of staff is in

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT ?name
WHERE {
  ?division a org:OrganizationalUnit .
  ?division org:unitOf <http://lincoln.ac.uk/> .
  ?division rdfs:label ?name .
  ?division org:hasMember <http://id.online.lincoln.ac.uk/person/$ID$> .
}

Get the department that a member of staff in is

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX org: <http://www.w3.org/ns/org#>

SELECT ?name
WHERE {
  ?division a org:OrganizationalUnit .
  ?division org:unitOf ?parent .
  ?division rdfs:label ?name .
  ?division org:hasMember <http://id.online.lincoln.ac.uk/person/$ID$> .
  FILTER (?parent != "http://lincoln.ac.uk/")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment