This document provides an adaptation of a webinar on querying linked data for Android devices using a modified triple store implementation. It outlines instructions for installing OntoQuad, deploying a preloaded MusicBrainz dataset, and includes sample SPARQL queries adapted from the original webinar to query the data within the limitations of mobile devices. The sample queries are demonstrated to retrieve album and track information for the band Queen from the loaded dataset.
1. Querying Linked Data on
Android
Module 2 adaptation for Android
enabled devices
07.04.2014 1
2. Outline
• This document complements to webinar
Module 2: Querying Linked Data
• It targets querying linked data on mobile
(Android) devices
• Original queries modified to correspond to
limited resources environments
• Triple store implementation by Ontos AG
(http:// www.ontos.com)
07.04.2014 2
3. Webinar Structure
• OntoQuad installation instructions
• Deployment of preloaded dataset in
OntoQuad
• Running sample queries against the
OntoQuad SPARQL endpoint
07.04.2014 3
4. OntoQuad Installation
• RDF store for Android
• Detailed setup instructions already provided
by Ontos AG (attached)
• Fresh installations should be started at least
once to initialize their data directory
structures
• OntoQuad should be completely stopped
before deploying preloaded datasets (next
slides)
07.04.2014 4
5. Prebuild dataset deployment
• Musicbrainz dataset extract
– 5 million RDF triples subset
– No special hardware requirements (<1GB
external storage)
– Sufficient deployment and query response
times
– Still representative for demonstration and
educational purposes
07.04.2014 5
6. Prebuild dataset setup
• Download the binary files archive
(musicbrainz-5m-bin.zip) on your PC
• Extract the archive on the local file system
– Important files and folders: ./vm, ./txlogs,
.universe, .commands
• Ensure OntoQuad in not active/running
before performing the next steps
07.04.2014 6
7. Prebuild dataset setup (2)
• Connect the mobile device via appropriate
USB cable to PC and overwrite the
existing files in folder:
/storage/extSdCard/margot/ with the ones
from the archive
• Disconnect the mobile device and start the
OntoQuad server
07.04.2014 7
8. Setup Verification
• Start the Admin Console and select the
SPARQL section (it will take some time)
• Execute the following query:
SELECT (COUNT(?s) as ?count)
WHERE { ?s ?p ?o }
• The result count value should be
approximately 5 million
07.04.2014 8
9. Module 2 for Android
• Based on original Webinar Module 2
content
• SPARQL queries adapted for the extracted
data set and the current implementation
limitations
• Each query description refers to the
original location in the Module 2
presentation
07.04.2014 9
10. Module 2 for Android (2)
• What albums did Queen make (slide 15) ?
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?album
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album a mo:Release ; dc:title ?title
}
ORDER BY ?title
07.04.2014 10
11. Module 2 for Android (3)
• What albums and tracks did Queen make
(slide 22) ?
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?album_name ?track_title
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album dc:title ?album_name ;
mo:record ?record .
?record mo:track ?track .
?track dc:title ?track_title . }
07.04.2014 11
12. Module 2 for Android (4)
• Retrieve the albums and tracks recorded by Queen,
where the duration of the song is more than 300 secs.
and no longer than 400 secs (slide 23)
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?album_name ?track_title ?duration
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album dc:title ?album_name ;
mo:record ?record .
?record mo:track ?track .
?track dc:title ?track_title ;
mo:duration ?duration;
FILTER (?duration > 300000 && ?duration < 400000) }
07.04.2014 12
13. Module 2 for Android (5)
• Retrieve the name of the albums recorded by
Queen which have at least two different
songs (slide 24)
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT DISTINCT ?album_name
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album dc:title ?album_name ;
mo:record ?record .
?record mo:track ?track1 .
?record mo:track ?track2 .
FILTER (?track1 != ?track2) }
07.04.2014 13
14. Module 2 for Android (6)
• Retrieve the duration of the albums recorded by
Queen (slide 25)
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
SELECT ?album ?album_name (SUM(?track_duration) AS ?album_duration)
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album mo:record ?record ;
dc:title ?album_name.
?record mo:track ?track .
?track mo:duration ?track_duration .
}
GROUP BY ?album ?album_name
HAVING (SUM(?track_duration) > 3600000)
07.04.2014 14
15. Module 2 for Android (7)
• Create the dc:creator descriptions for albums
and their tracks recorded by Queen (slide
29)*
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
CONSTRUCT {
?album dc:creator ?band .
?track dc:creator ?band .}
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album mo:record ?record .
?record mo:track ?track . }
*Note: CONSTRUCT queries might not work properly with the current implementation
07.04.2014 15
16. Module 2 for Android (8)
• Create the dc:creator descriptions of the
albums recorded by Queen whose title
contains the word 'rock’ (slide 31)*
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
CONSTRUCT { ?album dc:creator ?band }
WHERE {
?band foaf:name "Queen" .
?band foaf:made ?album .
?album dc:title ?album_name .
FILTER (REGEX(?album_name, ".*rock.*", "i"))
}
*Note: CONSTRUCT queries might not work properly with the current implementation
07.04.2014 16