Visualizing SPARQL Results in Tableau

Using Tableau to Launch Your Semantic Web of Linked Data Exploration

Daniel Heward-Mills
OpenLink Virtuoso Weblog
5 min readOct 18, 2017

--

Situation Analysis

In a typical SQL RDBMS, all Keys — whether Candidate, Primary, or Foreign — are scoped to a specific RDBMS instance. Once you enter the realm of distributed databases, these unique identifiers cease to be unique.

What is a Super Key?

A Super Key is an identifier that unambiguously names its referent — the entity it identifies — regardless of the context in which it is encountered. When looked up (dereferenced), a Super Key always resolves to a description of its referent, without any operating system, RDBMS instance, platform, or other dependency.

On an HTTP-based network, whether public or private, hyperlinks (HTTP URIs) can serve as such Super Keys, and provide a powerful mechanism for enhancing Reports and Dashboards produced by Business Intelligence and Analytics oriented productivity tools.

Super Keys and Business Intelligence & Analytics

Reports and Dashboards are fundamentally insight-oriented projections of data in context. Using hyperlinks — Super Keys — as entity names enables every reader to perform additional ad-hoc exploration without the need to create yet another report.

Virtuoso can add these identification and exploration capabilities to existing Business Intelligence or Analytics tools, even if they don’t use a specific data protocol.

The rest of this post demonstrates the use of Virtuoso to inject Super Keys into Tableau reports.

Enhancing Tableau, courtesy of Virtuoso Super Keys

Prerequisites:

  • A working ODBC connection to a Virtuoso Instance
  • Any ODBC or JDBC Compliant version of Tableau or Tableau Server

(1) Open Tableau and Click on Other Databases (ODBC).

(2) Select your Virtuoso DSN and click Connect. When prompted, enter your login credentials, and click OK.

(3) The connection attributes of your DSN will be added to Tableau’s native ODBC administrator. When these attributes are shown, click Sign In.

(4) Select any database from your Virtuoso instance, and click on New Custom SQL. Copy and paste the following query:

SELECT DISTINCT 
DBpedia.name AS "Actor",
DBpedia.actor AS "Actor ID",
DBpedia.school AS "School ID",
DBpedia.schoolLabel AS "School"
FROM
(
SPARQL
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?actor
?school
?name
?schoolLabel
WHERE
{
SERVICE <http://dbpedia.org/sparql>
{
?actor
dct:subject <http://dbpedia.org/resource/Category:Tony_Award_winners> ;
<http://dbpedia.org/ontology/almaMater> ?school ;
foaf:name ?name .
?school
rdfs:label ?schoolLabel .
FILTER ( LANG(?name) = "en" )
FILTER ( LANG(?schoolLabel) = "en" )
}
}
ORDER BY ASC(?school)
LIMIT 100
) AS DBpedia

(5) Click OK to enter the Data Source window. Click Update Now to see a preview of results.

(6) Drag the required rows into the Rows field, and select Actions from the Worksheet menu.

(7) Click the Add Action > button, and select URL.

(8) Use the name text-box to select Actor as the target for hyperlink text, and Actor ID as the anchor URI target. Set Run action on to Select.

(9) Repeat for School and School ID; then click OK.

(10) Each row item in the Actor and School columns is now anchored by a DBpedia ID (hyperlink) that resolves to an external DBpedia page that describes the entity uniquely identified by that hyperlink.

(11) For example, click on the hyperlink that identifies Al Pacino and it will resolve to his DBPedia page.

(12) You can further edit this table by removing columns and resizing the abc measurements column if desired. This demonstration can be published on Tableau Public or any Tableau Server instance.

Conclusion

In this post I’ve demonstrated how Virtuoso enhances an existing productivity tool (Tableau BI, Public Edition) by injecting Super Keys (in the form of DBpedia identifiers) into SPARQL Query Results returned as a CSV document. In a nutshell, Tableau Public becomes a powerful productivity tool for non-programmers that provides navigation and visualization over a Semantic Web of Linked Data.

Most important of all, technology investments that aren’t ODBC or JDBC compliant, but that do accept CSV data via file upload or from local OS clipboard, can still be used to exploit the power of a Semantic Web of Linked Data without triggering expensive and failure-prone “rip and replace” misadventures.

Related

--

--