SPARQL Querying Using RDF Studio

Next: Build A Basic Ontology Using The SmartRDF Editor

RDF Studio's SPARQL querying tool helps complete your SPARQL query for you with autocompletion features. We show you how to query your RDF model using a simple example.

After this tutorial, you should be able to:

  • Construct a basic SPARQL query using the SPARQL editor.
  • Execute the query on your model.
  • Copy the results to the clipboard for use in other programs.

Estimated time: 5 minutes

You should have already understood the following lesson (and pre-requisites) before you begin:

To begin this short tutorial, open plants.rdf as we learned how to do in the Quick Start Tutorial.

1. Enter A Simple Query With Autocomplete

Now you are ready to query the model using SPARQL. To do this in RDF Studio, expand the plants.rdf node in Model Explorer, and double click on the SPARQL Query node as shown below:

You should then see the SPARQL Query view open. To start with, start typing the common SPARQL query keyword SELECT like so:

As you can see, as you start typing RDF Studio automatically presents you with the most likely options you are typing as you complete your query. If you select a particular autocomplete option in the dropdown, the tooltip will show you extra help to guide you in what the SPARQL syntax means.

2. Execute A Simple Query

Let's enter a simple query that returns all the instances in the data that reside within the plants:flowers class (i.e. the classification of flowering plants).

Unfamiliar with SPARQL basics? We recommend you start with our acclaimed SPARQL Querying primer tutorial to get you started.

Continue typing your query and enter the simple query below:

PREFIX plants:   <http://www.linkeddatatools.com/plants#>
SELECT ?planttype WHERE {
  ?planttype a plants:flowers.
}
ORDER BY ?planttype

You should see something like the below view:

Notice that the SPARQL has been highlighted to make it easier to see the components of our query. You will also notice we have a result returned, as can be seen in the Result Set (lower part of the view).

To finish this tutorial, copy the result set to the clipboard. Click the 'Copy As XML' button (bottom right) and paste into notepad - you'll see the SPARQL result set format in XML. You can use this in other programs, or save it and send to others.

You have completed this tutorial. You should now understand the following:

  • How to type a basic SPARQL query in RDF Studio, making use of autocomplete.
  • How to execute that query on the model.
  • How to copy the result set to the clipboard so that you can paste it into other programs.

You should now be able to start the following tutorial:

 

Add comment

Security code
Refresh

Community

Register to download software from our site and interact with other users as you learn semantic web.