Skip to content

Getting Started

GCHQDeveloper81 edited this page Jul 16, 2024 · 9 revisions

Welcome! This page contains a few guided tutorials to introduce you to some of the core features of LD-Explorer. These tutorials assume that you already know the basics of working with linked data. If this is not the case, please check the Resources page.

You might find it helpful to open this page in a new tab or on another monitor if you are following along.

Explore a remote data source

This first tutorial explains how to use LD-Explorer to add a remote source to your list of active sources.

  1. Select Sources from the left hand menu. From here you can either add your own remote source or you can select one from the catalog. For the purposes of this tutorial, add the Sherlock data source from the Internal/Demo section of the catalog.
  2. Return to the Sources page and confirm that your remote data source is now listed as being enabled in green. You can click the Show button to view more details about a particular source or to browse some sample data from it.
  3. Select Explore from the left hand menu to begin exploring the classes, properties and instances within your active data sources.

You should be able to see that this particular dataset defines one class, Person, and does so using the FOAF (Friend of a Friend) vocabulary. You should also see that the dataset contains two instances of that same class, and that the two instances are mortal enemies!

Note that each page has a dropdown near the top saying View SPARQL query - clicking this will show you the SPARQL query that was used to generate the data on the page.

Create a local data source

LD-Explorer includes functionality which allows you to work locally with RDF data rather than having to read it in from remote locations.

  1. Select Sources from the left hand menu and click the Add Local Source button. Fill out the form, giving your new data source any name you like.
  2. Identify your new data source within the list of active sources and click the Import data button.
  3. Leave the import format as "RDF" and paste some RDF into the form - here is the same Sherlock data from the last example which you can use for the purposes of this tutorial.
@base <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rel: <http://www.perceive.net/schemas/relationship/> .

<#sherlock_holmes>
    rel:enemyOf <#james_moriarty> ;
    a foaf:Person ;
    foaf:name "Sherlock Holmes" .

<#james_moriarty>
    rel:enemyOf <#sherlock_holmes> ;
    a foaf:Person ;
    foaf:name "James Moriarty" .
  1. After importing this data, note that your newly created local data source now contains 7 triples extracted from the RDF document above. You can now use the Explore menu to browse this data just as you did with the remote source.

Run a SPARQL query against an active data source

LD-Explorer supports running SPARQL queries across datasets, regardless of whether they are remote or local.

  1. Re-add the Sherlock data if it's not already an active data source by following one of the above guides (local or remote).
  2. Click SPARQL from the left hand menu to bring up the SPARQL UI. Submit the following query to bring back the name and class of any individuals in the dataset.
SELECT ?entity ?class
WHERE { ?entity a ?class } 
LIMIT 100

You should see a table displaying the details of our old friends Sherlock and Moriarty.

These queries are run across all active data sources - this is made possible by the Comunica query engine which works by creating a virtual local graph containing all triples from all data sources and running the query against that graph. As this is all happening within the browser's memory, you cannot use LD explorer to manage large amounts of data locally. That said, Comunica and LD Explorer work by streaming triples, meaning that the data sources themselves can still be absolutely massive.

Persisting results to a local data source

LD Explorer lets you persist the results of a SPARQL CONSTRUCT query into one of your local data sources.

There are a few reasons you might want to do this: It may be that you have run a particularly interesting query and you would like to save the resultant triples into a local data source in order to work with them further, for example you may have performed some inference and then want to perform a follow-on query that includes the newly inferred triples. It might also be that you want to pull some relevant data from a massive dataset, persist them in a local data source, and then run queries on just that local subset (queries which might otherwise be too expensive to run directly on the remote dataset itself).

  1. Click Sources from the left hand menu, followed by the Add Local Source button. Call your new data source anything you like (e.g. "Persisted Data").
  2. Re-add the Sherlock Data as per above steps if it's not already an active data source. You should now have two data sources: A local one you created in the last step and the Sherlock data.
  3. Run the following SPARQL query using the SPARQL UI - it performs the inference that anyone who is an enemy of someone else therefore also knows that person.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX per: <http://www.perceive.net/schemas/relationship/>

CONSTRUCT { ?a foaf:knows ?b }
WHERE { ?a per:enemyOf ?b }
  1. The results screen looks a bit different to the ones you've seen thus far - this is because you ran a CONSTRUCT query, which means the results are themselves also a graph (you can in fact switch to graph view to see this data visualised as a graph).
  2. A new option should be available just below the query status called "persist results to local data source". Click this, and persist the results away to the local source you created in step 1.
  3. Return to the Sources page using the left hand menu - note that your source now appears to have 2 triples in it! You can click the Show button to view a sample of this data, confirming that this is indeed the two triples you just persisted.
  4. As a bonus, click on one of the two records (Sherlock or Moriarty). This will take you through to their Describe page which should now be telling you that not only are these people enemies, but they also know each other. This demonstrates Comunica/LD Explorer's ability to federate queries - this page was generated by running one query over multiple data sources!

This small example demonstrates some of the power of Linked Data and RDF - it allows us to transform and wrangle our graph data across multiple data sources without writing a line of code ourselves. LD Explorer comes with a bunch of pre-written SPARQL queries representing some of the more common inferences that users may want to perform.