wiki:bindingVariables

Version 13 (modified by nixdell, 8 years ago) (diff)

--

VIQUEN: A Visual Query Engine for RDF

Tutorial 2: Binding unknown variables using WHERE clauses

In this tutorial, you will work through constructing a query that contains variables, or unknowns. These variables are specified in the query and then bound to sets of RDF triples through the use of a WHERE clause.

Specifically, we are going to write a query to discover all of the direct properties of things that are "constitutional parts" of the "Liver" node in the FMA.

NOTE: This tutorial will not focus on how to use the execution environment or the visualization environment.
For information on how to use the execution environment, see part 2 of tutorial 1.
For information on how to use the visualization environment, see part 3 of tutorial 1.
For general information on the system, see the main VIQUEN documentation.

Step 1: Start VIQUEN

Navigate to the VIQUEN directory and launch the application. You should start with a new, empty query-building workspace.

Step 2: Add a "Start" node

Adding a "Start" node to the workspace indicates to the query compiler the node from which to start compiling the query. On the left-hand side of the screen, you can find the operations palette. Click on the blue "Start" icon, hold the mouse button down and drag the icon into the workspace. Release the mouse button and you will see that you have added a "Start" node to the workspace.

Step 3: Add an "Input" node

We need to specify the input data sources that will be used in the query. In the same way that you added the "Start" node, now add an "Input" node to the workspace (click and drag the input icon from the operation palette into the workspace). Click on the "Select input sources" button in the "Input" node and make sure that the "FMA" is selected as an input source.

Step 4: Add an "Extract Edges" node

We want to extract a subset of edges from the FMA. The operation that fits our need is the "Extract Edges" operation. Switch to the "Extract" operation palette and add an "Extract Edges" node by clicking on the "Extract Edges" icon and dragging it into the workspace.

Step 5: Change the "Extract Edges" parameters

Our next step is to set the required query parameters for the "Extract Edges" node.
From the "From Graph" drop-down list, select the "fma", since this is the graph that we will extract the edges from.

We now need to specify the RDF triple pattern for the edges that we want. We know that we want the direct properties of the constitutional parts of the liver node. To do this, we create several variables. A variable is indicated using the "?" symbol.
Double click on the subject field of the triple and create a variable "?liver_part" as the subject of the RDF triple pattern.
Double click on the property field of the triple and create a variable "?direct_property" as the property of the RDF triple pattern.
Double click on the object field of the triple and create a variable "?something" as the object of the RDF triple pattern.
Thus we have created the triple pattern "?liver_part" -> "?direct_property" -> "?something".

Step 6: Add a "WHERE" clause

Before we can bind the variables that we created in the previous step, we need to add a "WHERE" clause to the "Extract Edges" operation. The type of "WHERE" clause that we need is "Match Statements" since we want to match our variables to statements in the data set.

At the bottom of the "Extract Edges" node, you can see the label "ADD WHERE CLAUSE".
Make sure that the drop-down list is set to "Match Statements" and then click on the "Add" button.
You will see that a blue "Where Match Statements" node has been added to the workspace, and it is connected to the "Extract Edges" node.

Step 7: Change the "WHERE" clause parameters

Our next step is to set the "WHERE" clause query parameters.
From the "From Graph" drop-down list, select the "fma", since this is the graph in which we will bind the variables.

We now need to specify the RDF triple pattern for the variable bindings. We know that we want the direct properties of the constitutional parts of the liver node. We can construct this pattern using two triples:
(1) A triple to get the constitutional parts of the liver. (2) A triple to get the direct properties of these constitutional parts.

Add another triple to the "WHERE" clause node by clicking on the (+) button located directly below the "From Graph" drop-down.

For the first triple:
We find the constitutional parts of the liver.
Double click on the subject field of the triple and select "fma:Liver" as the subject of the RDF triple pattern.
Double click on the property field of the triple and select "fma:constitutional_part" as the property of the RDF triple pattern.
Double click on the object field of the triple and bind the variable "?liver_part" as the object of the RDF triple pattern.

For the second triple:
We bind the variables that we specified in the "Extract Edges" node.
Double click on the subject field of the triple and bind the variable "?liver_part" as the subject of the RDF triple pattern.
Double click on the property field of the triple and bind the variable "?direct_property" as the property of the RDF triple pattern.
Double click on the object field of the triple and bind the variable "?something" as the object of the RDF triple pattern.

Thus we have created the triple pattern:
"fma:Liver" -> "fma:constitutional_part" -> "?liver_part" "?liver_part" -> "?direct_property" -> "?something".

We have now successfully created the variables to extract the information from the FMA, and bound the variables in a "WHERE" clause.

Step 8: Add the "Output" node

Add an output node to the query by clicking on the "Output" icon in the operations palette and dragging it into the workspace. By default, the output location is set to "http://localhost/set1". For this query, it is not necessary to change the output location so we leave it as it is.

Step 9: Connect the query components

We now need to add directed edges to the workspace to direct the flow of the query.
Add an edge to the workspace by clicking on the "Edge" icon in the operations palette and dragging it into the workspace.

Click on the source of the edge and drag it to the "Start" node. When the "Start" node highlights green, release the mouse button. The edge will now have the "Start" node as its source.
Repeat this procedure for the other end of the edge, but connect it to the "Input" node.

Step 10: Finish constructing the query

Repeat step 9 except add the edge from the "Input" node to the "Extract Edges" node.
Repeat step 9 except add the edge from the "Extract Edges" node to the "Output" node.

IMPORTANT NOTE: The edge to the "Output" node is from the "Extract Edges" node and NOT the "Where" node.

Step 10: Compile and execute the query

Congratulations! You have finished formulating the query. Click on the "compile query" button to compile the query and open the execution environment. Run the query and visualize the results (if you do not know how to do this then please review tutorial 1 parts 2 and 3). HINT: This query should return 111 RDF triples.

For information on how to use the execution environment, see part 2 of tutorial 1.
For information on how to use the visualization environment, see part 3 of tutorial 1.
For general information on the system, see the main VIQUEN documentation.

Attachments