This post will have some of the more interesting queries that our meeting resulted in, but I will be leaving out the prefixes for them later. The prefixes used were:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX tw: <http://tw.rpi.edu/schema/>
PREFIX twi: <http://tw.rpi.edu/instances/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

Today I worked with Cameron on a SPARQL visualization exercise, which will end with a visualization of some data retrieved by a SPARQL query, using the Google visualization API.  As it turns out, we spent a while constructing various queries.  We had started by looking at a simple SPARQL query that simply retrieved all the data for one of us in RDF form, followed by each of us trying to figure out how to pull both of our information at once, finally ending in the following query:

DESCRIBE ?s
WHERE {
?s a foaf:Person.
?s foaf:name ?o.
FILTER (?o = "Philip Ng"@en || ?o = "Cameron Helm"@en)
}

I basically arrived at this after figuring out what the actual triples were by starting out with a SELECT on ?s ?p ?o, then building the filter/query to match what I wanted, thus why the query still has the first and last variables with those names.  After this query, we wanted to try to build one to come up with a table of all of the undergraduates.  We first tried a query using tw:hasRole, but found out that for some reason, that doesn’t seem to result in the triples at all, where all of the predicates have blanks as their object.  We decided to go further out first, and resulted in this query:

SELECT ?s ?p ?o
WHERE {
?s a foaf:Person.
?s tw:hasAffiliation twi:TetherlessWorldConstellation.
}

I had left in the ?p and ?o so I could see the various kinds of results returned for each person, looking for interesting data that we could try to build queries around next.  There were a whole bunch of queries here, but none as interesting, mostly just playing around with various combinations of triples and filters to see what would result. After a bit, I noticed the location triples for everyone, and quickly changed the query to the following:

SELECT ?Researcher ?ResearcherName ?Location
WHERE {
?Researcher a foaf:Person.
?Researcher foaf:name ?ResearcherName.
?Researcher tw:hasAffiliation twi:TetherlessWorldConstellation.
?Researcher tw:hasLocation ?Location.
}

This pulls all the affiliated people once again, but also their locations.  At this point, we realized that since all of the undergraduates should be in the same room, and only the undergraduates, that we had found an indirect way to get our original goal:

SELECT ?UndergradStudent ?UndergradStudentName ?Location
WHERE {
?UndergradStudent a foaf:Person.
?UndergradStudent foaf:name ?UndergradStudentName.
?UndergradStudent tw:hasAffiliation twi:TetherlessWorldConstellation.
?UndergradStudent tw:hasLocation ?Location.
FILTER( ?Location = twi:RPI_Winslow_1148A )
}

However, for the visualization part, I was thinking of using the one before, with all the TWC users and their locations, to graph the rooms and the number of people in each one, since the undergrad query is interesting but doesn’t really have anything graphable.  We did not actually finish with the visualization part, without enough time to figure out how to get a JSON translation compatible with the Google API, but we were pretty satisfied with our query work, and left feeling much more comfortable with SPARQL.

The SPARQL endpoint that we used while doing this was at http://wineagent.tw.rpi.edu:2020/query.html

Advertisements