Querying Data

What’s in this document?

To manage and query your data, click the SPARQL menu. The SPARQL view integrates the YASGUI query editor plus some additional features, which are described below.

Hint

SPARQL is an SQL-like query language for RDF graph databases with the following types:

  • SELECT - returns tabular results;
  • CONSTRUCT - creates a new RDF graph based on query results;
  • ASK - returns “YES”, if the query has a solution, otherwise “NO”;
  • DESCRIBE - returns RDF data about a resource; useful when you do not know the RDF data structure in the data source;
  • INSERT - inserts triples into a graph;
  • DELETE - deletes triples from a graph.

The SPARQL editor offers two viewing/editing modes - horizontal and vertical.

_images/sparql1.png

Use the vertical mode switch to show the editor and the results next to each other, which is particularly useful on wide screen. Click the switch again to return to horizontal mode.

_images/sparqlVertical.png

Both in horizontal and vertical mode, you can also hide the editor or the results to focus on query editing or result viewing. Click the buttons Editor only, Editor and results, or Results only to switch between the different modes.

  1. Manage your data by writing queries in the text area. It offers syntax highlighting and namespace autocompletion for easy reading and writing.

    Tip

    To add/remove namespaces, go to Setup -> Namespaces.

  2. Include or exclude inferred statements in the results by clicking the >> icon. When inferred statements are included, both elements of the arrow icon are the same color (ON), otherwise the left element is dark and the right one is greyed out (OFF).

  3. Execute the query by clicking the Run button or use Ctrl/Cmd + Enter.

    Tip

    You can find other useful shortcuts in the keyboard shortcuts link in the lower right corner of the SPARQL editor.

  4. The results can be viewed in different formats corresponding to the type of the query. By default, they are displayed as a table. Other options are Raw response, Pivot table and Google Charts. You can order the results by column values and filter them by table values. The total number of results and the query execution time are displayed in the query results header.

    Note

    The total number of results is obtained by an async request with a default-graph-uri parameter and the value http://www.ontotext.com/count.

  5. Navigate through all results by using pagination (SPARQL view can only show a limited number of results at a time). Each page executes the query again with query limit and offset for SELECT queries. For graph queries (CONSTRUCT and DESCRIBE), all results are fetched by the server and only the page of interest is gathered from the results iterator and sent to the client.

  6. The query results are limited to 1,000, since your browser cannot handle an infinite number of results. Obtain all results by using Download As and select the required format for the data (JSON, XML, CSV, TSV and Binary RDF for SELECT queries and all RDF formats for Graph query results).

Save and share queries

Use the editor’s tabs to keep several queries opened while working with GraphDB. Save a query on the server with the Create saved query icon.

_images/save-query.png

When security is ON in Setup -> Users and Access menu, the system distinguishes between different users. The user can choose whether to share a query with others, and shared queries are editable by the owner only.

Access existing queries (default, yours, and shared) from the Show saved queries icon.

_images/open-query.png

Copy your query as a URL by clicking the Get URL to current query icon.

When Free access is ON, the Free Access user will see shared queries only and will not be able to save new queries.

Interrupt queries

You can use the Abort query button in the SPARQL Editor to manually interrupt any query.

_images/editorWithAbort.png