querying linked data on android
DESCRIPTION
Querying Linked Data on AndroidTRANSCRIPT
13.04.2023 1
Querying Linked Data on Android
Module 2 adaptation for Android enabled devices
13.04.2023 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)
13.04.2023 3
Webinar Structure
• OntoQuad installation instructions• Deployment of preloaded dataset in
OntoQuad• Running sample queries against the
OntoQuad SPARQL endpoint
13.04.2023 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)
13.04.2023 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
13.04.2023 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
13.04.2023 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
13.04.2023 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
13.04.2023 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
13.04.2023 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 ?albumWHERE { ?band foaf:name "Queen" . ?band foaf:made ?album . ?album a mo:Release ; dc:title ?title} ORDER BY ?title
13.04.2023 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_titleWHERE { ?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 . }
13.04.2023 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 ?durationWHERE { ?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) }
13.04.2023 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_nameWHERE { ?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) }
13.04.2023 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_nameHAVING (SUM(?track_duration) > 3600000)
13.04.2023 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
13.04.2023 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
13.04.2023 17
Module 2 for Android
Thank you!