Welcome to SparqlBlocks

The aim of SparqlBlocks is to let you visually build queries against Linked Data sources.

Although SparqlBlocks is based on SPARQL (the standard query language for Linked Data) you do not need to know SPARQL syntax to use SparqlBlocks.

This tutorial will help you get started. Each step explains a new concept and lets you experience it in action.

Workspace and Blocks

The main area of the app is the workspace. Here you can drag and connect together the blocks that will form queries.

On the left there is the toolbox, where you can pick the blocks to use. They are grouped in categories ( Query,  Patterns,...).

click on the  Query category and drag the query block to the Workspace.
Queries and Patterns

A query block executes queries against a Linked Data source (the default source is DBpedia).

Linked Data sources are graphs (networks) of concepts. A query is built with patterns to be matched against the input graphs.

The pattern itself contains an inner part that we call branch. A pattern is rooted on a node of the graph (in this case subj) and may hold any number of branches.

The pattern inside the query has actually a lighter shade of color, to indicate that these blocks are there by default. They can be replaced by other blocks or changed, becoming then regular blocks.


The query is remotely executed and the table of results is shown below. There is a result row for each way the pattern is matched against the input graph (although only the first 5 rows are shown).

This is the most generic pattern, that match every connection (triple) in the input graph.


The blocks subj, pred, and obj are variables. For each matching of the pattern, each variable is bound to the corresponding value in the input graph. In the table of results, the rows are the matchings and the columns are the variables.

Navigate and Zoom the Workplace

To organize the workspace you can:

  1. move blocks around by dragging them
  2. navigate the workspace
    • by clicking on the background and dragging it or
    • by using the scrollbars
  3. zoom in/out workspace by using and
  4. reset workspace view by using

Keyboard Commands

You can use the following common keyboard commands:
  • Del or to delete the selected block;
  • Ctrl + C to copy the selected block;
  • Ctrl + X to cut the selected block;
  • Ctrl + V to paste the block that have been copied/cut;
  • Ctrl + Z to undo last operation;
  • Ctrl + Shift + Z to redo an operation that was undone.

Alt or can be used in place of Ctrl.

Delete Blocks

There are in total four ways to delete blocks:
  1. select the block and type Del or ;
  2. right-click on the variable block and choose Delete Block;
  3. drag the block to the trash bin ;
  4. drag the block to the left, over the toolbox.
From Variables to Fixed Values, Resources

Variables in the pattern may be replaced by resources (concepts) and literals (strings, numbers,...), to represent fixed parts of the pattern.

from the  Vocab > FOAF category, drag the foaf:knows branch to the query pattern, replacing the existing branch - pred -> obj.
Grow your Pattern

Now the query looks for pairs of resources linked by foafknows —that is, two persons that know each other. Resources used to identify the type of a link, like foafknows, are called properties.

Things get interesting when patterns are composed of multiple links. Add a new branch to your pattern to look for the name of subj.

  1. foafnamename
    from the  Vocab > FOAF category, drag the foaf:name branch in the existing query pattern.
Results are Blocks too!

The values in the table of results are also blocks, resources and literals. They can be used to change the current query or create new queries.

from the table of results, under the header subj, drag one of the results to the pattern above, to replace the variable subj.
Grow the Pattern Again 1/2

The query may contain multiple patterns. Add another pattern to get data about the people that are friends of this person.

  1. personrdftypefoafPerson
    from the  Vocab > FOAF category, drag the foaf:Person pattern, after the existing pattern;
  2. click on the variable person and change it to use friend instead.
Grow the Pattern Again 2/2

Get the name of the friends too.

  1. foafnamename
    from the  Vocab > FOAF category, drag again the foaf:name branch, inside the new pattern;
  2. click on name1 and Rename variable... as friendName.
Order Results

Results by default are not given in any particular order. You can order them based on the content of one or more variables, in ascending or descending order.

  1. drag a copy of the variable friendName from the  Variables category to the field;
  2. change the order direction from ▲ (asc.) to ▼ (desc.);
Limit Results

You can increase or reduce the maximum number of rows you see by changing the value of the limit field.

  1. set the value of the field to 3.
Filter Results

You can filter the results according to a logic expression of your choice. For example we may request to see just the friends containing the string “tim” in the name.

  1. from the  Logic category, drag a filter block to the query (before, among, or after the existing patterns);
  2. bcabcd
    from the  Text category, drag a contains block inside the filter;
  3. drag the variable friendName in place of abcd;
  4. change the text “bc” to “tim”.
Look for Classes of Resources

Resources have types, that are other resources. This resources used as types are called classes.

There is a pre-built query to look for them.

  1. you may delete the whole query block now;
  2. from the  Search category, drag the search Classes block in the workspace;
  3. change the text “abc” to “lake”;
  4. pick from the results the class found for lakes (under column class) and drag it to any place in the workspace;
  5. drag also the corresponding pattern (under column pattern) to any place in the workspace.
Look for Resources

There is also a pre-built query to look for any kind of resource. Optionally you can indicate the type of the resource.

  1. you can delete the search Classes block;
  2. from the  Search category, drag the search Resources block in the workspace;
  3. replace owlThing with dboLake;
  4. change the text “abc” to “titicaca”;
  5. pick from the results the resource found for Lake Titicaca (under column resource) and drag it to any place in the workspace.
Look for Properties

There is also a pre-built query to look for properties. Properties identify a "type of link" between resources. For each property, the class of resources from which the links come from is called domain, while the class towards which the links go is called the range.

You can indicate none, one or both of the specific classes between which you want to use the property. The actual domain and range of the property may be classes that are more generic.

  1. you can delete the search Resources block
  2. from the  Search category, drag the search Properties block in the workspace;
  3. connect dboLake to the from class input; if you lost this resource or any used resource, you can find them back in the  Resources category;
  4. change the text “abc” to “located”;
  5. pick from the results the branch found (under column branch)and drag it to any place in the workspace.
Build a Query from Patterns and Branches found with Search

You can directly use the patterns and branches obtained from search Classes and search Properties to build queries.

  1. you can delete the search Properties block
  2. drag a new query block in the workspace;
  3. lakerdftypedboLake
    replace the query pattern with the one obtained from search Classes pattern;
  4. dbolocatedInArealocated in area
    add the branch obtained from search Properties.
Save and Share

You can save the current state of the Workspace anytime. It is associated to a link (URL) that you can share and/or keep yourself for future reference.

Technically, the workspace content —along with the history since last save/load— is saved on GitHub as a secret anonymous Gist. That means access is resctricted to people having the link.

  1. press the Save as Gist button;
  2. copy the link from the address bar of the browser or pressing the Copy Link button;
  3. paste the link somewhere to save and/or share it;
  4. when anyone opens that link, she/he will get the state of the workspace at the moment you saved it.
Congratulations! You learned the basics of SparqlBlocks!

Some pointers to other useful stuff:
  • the  Patterns category contains more blocks to build patterns;
  • the  Compose category contains blocks to compose patterns into complex queries;
  • the categories  Logic,  Math, and  Text allow you to build filters with different kinds of literals;
  • the context menu (right-click) of each block has other options, like
    • Add Comment —to add a note to it,
    • Collapse/Expand Block —to temporary reduce its extent,
    • Disable Block —to temporary consider it as not existent;
  • the context menu of a query block has the specific options
    • Save Query as SPARQL —to save the query as SPARQL in the local filesytem,
    • Open Query in YASGUI —to open the query in YASGUI (an online SPARQL editor),
    • Save Results as JSON —to save the results as JSON in the local filesytem.
Evaluation of SparqlBlocks

X)The longest river is{ "id": "0", "answerMD5": "b3aa0a5b32a2cf84b377a389b6250e31" }
In the category  Test there is a set of blocks that are statements with a missing part. Try to solve them through Linked Data queries!

The suggested method is to
  1. retrieve —through appropriate queries— the needed resources (classes, properties, entities)
  2. with the resources found in the previous step, design the query that solves the problem.

X)The longest river is{ "id": "0", "answerMD5": "b3aa0a5b32a2cf84b377a389b6250e31" }dbpediaAmazon_River
When you have found the block that is the solution, drag it inside the corresponding test block. After solving as much tests as possible, save the workspace, copy the link, and past it back on the evaluation form.

As the aim is to evaluate this system, please avoid using your personal background knowledge or external systems to solve these tests.

Notice on User Privacy

By using this tool you acknowledge the collection of usage data for improving the tool and research purposes.

For any questions or special requests you can contact privacy@sparqlblocks.org.