Interactive SPARQL Query Builder: Basic Tutorial

Creating RDF Instance Data using iSPARQL

  1. Go to http://cname/isparql, for ex. http://id.myopenlink.net/isparql
  2. The iSPARQL initialization window will be shown:



  3. Finally will be presented the iSPARQL Advanced tab open with a default SPARQL query:

    SELECT * WHERE {?s ?p ?o}





  4. Go to QBE tab:



  5. Click the Clear Pane icon on the toolbar to empty the Canvas.







  6. Next we will import the Schemas that contain the Terms to be used in the our Graph Pattern. In the Schemas pane enter http://rdfs.org/sioc/types# and click the "Import" button. Perform the same steps for the schema with URL: http://rdfs.org/sioc/ns#
  7. As result the Schemas window under "unbound", you should now see the items sioct and sioc.



  8. Now click on the sioct -> Classes -> + icon in order to expand the classes list:



  9. Scroll down the shown list and drag-and-drop the Subject Node Weblog onto the QBE working Canvas.



  10. As result should be created a Subject node of Datatype sioct:Weblog at the point you dropped it.
  11. The properties of the selected node are shown in the Subject Node pane where you can:
    1. Change the Node type to URI or Literal;
    2. Change the Node Variable label value;
    3. Set the Node Datatype;
    4. Set the visibility property of the variable by hatching the "Visible?" check-box;
    5. Set participation in the "Order By" clause bz hatching the "Order By" check-box:



  12. You can add a new node from the QBE toolbar. Click the Add mode icon, and drag-and-drop an Object Node onto the Canvas.



  13. In the Object Node pane, change the type to Literal and change the Variable label value to ?s.



  14. You can add a Datatype to a node through the Schemas pane or enter it manually. To use the Schemas pane --
    1. Import the schema that contains the terms you wish to use in your Graph Pattern. For ex. import the foaf schema: http://xmlns.com/foaf/0.1/



    2. Drag-and-drop the Class Document item from the Concepts list over the Node with Literal type that we created above.
    3. You should now see that the Datatype in the Node pane for the selected node has changed, from Literal to foaf:Document.



  15. To delete a node, select the desired node, e.g., the Node with Variable label ?s, and click the Remove button in the QBE toolbar. You will be prompted to verify deletion. Click OK to delete.



  16. You can add more nodes:



  17. Add connections by clicking the Connector icon on the QBE toolbar and drag from one node to another.
    1. For example, drag a connection from the node with Variable label ?forum to the ?post node.
    2. A connection will now be shown between the two nodes and a Connector pane will be shown above the Schema pane; this is the property window for the currently selected connection.



    3. Enter for Name for ex. sioc:container_of and un-hatch the Visible? check-box.



    4. Click the Connector icon from the QBE toolbar and drag from the ?post node to to the ?maker node.



    5. In the Connector pane, check the Optional? check-box and un-hatch the Visible? check-box.



    6. Now we will add a type (from the foaf schema) to this connection. The type can be an Attribute (A) or Relationship (R) property from the Schema pane. "Attribute" (A) items are shown under each imported Schema's Properties with a green letter "A" icon. "Relationship" (R) items are shown under each imported Schema's Properties with a blue letter "R" icon. In the Schemas pane, go to foaf -> Properties and drag the "Relationship" (R) property maker onto the selected connection on the Canvas.
    7. In the Connector pane, the value of the Name field will change to foaf:maker. Note that the connection line between the nodes ?post and ?maker is not solid, because we set it to be optional in the Connector window:



    8. Click the "Connector" icon from the QBE toolbar and drag from the ?maker node to the ?nick node.



    9. In the Connector window hatch the Optional? check-box and un-hatch the Visible? check-box. Enter foaf:nick for Name.



  18. The Final Graph Model can be viewed in the QBE working pane.



Querying

  1. We now have the final graph model. Before using it in a query, we need to set a proper target Graph URI. For this, change the value in the Data Source URI field for ex. to http://id.myopenlink.net/dataspace



  2. Click the Run Query button on the QBE toolbar.
  3. The query results will be shown in the Results tab.



  4. You can also change dereferencing:
  5. View the SPARQL parameters values in the SPARQL Params sub-tab:



  6. View the response values from the Response sub-tab:



  7. View the SPARQL query produced from the graph model you have built from the Query sub-tab:



Saving the Graph Model

  1. Go to QBE tab and click the Save As icon from the QBE toolbar.
  2. As result should be shown the WebDAV Browser:



  3. Select a destination folder, input a file name, for e.g., MySimpleTest, and select SPARQL Definitions (*.rq) for File type. You may also save the query in XML format, by choosing Dynamic Data Web Page (*.isparql) for File type.



  4. Click "Save".

Generating a SPARQL Query from the Graph Model

  1. Go to QBE tab.
  2. Click the Generate icon on the toolbar.
  3. The Advanced tab will open, with the query generated from your Graph in the SPARQL Query text-area.



  4. Use the Prefixes, Templates, and Statement Help drop-down lists above the SPARQL Query text-area to format the query.
    • Note: You can revert your changes by clicking the "Get from QBE" button on the Advanced tab toolbar.



  5. Now in the SPARQL Query Working area of the Advanced tab, add a new optional node to the query for foaf:phone.



  6. To apply the query changes to the Graph model, click the "Visualize" button on the Advanced tab toolbar.



Setting Results Rows

  1. Go to the QBE tab.
  2. At the bottom of the page change in "Query options" the Resize site limit value, for ex. to 10:



Adding a dataset

  1. On the QBE toolbar, click the Dataset button.
  2. Choose Type and enter a Data Source URI value.
  3. Click the Add button.



Other iSPARQL Features

Auto arrange the Graph Model

  1. Go to the QBE tab.



  2. Click the Auto arrange icon on the toolbar.
  3. The Graph model layout will be re-arranged to a more compact form.



Group selected nodes of the Graph Model

  1. Go to the QBE tab.
  2. Select several nodes from the Graph. You can do this by holding the "Shift" (on Windows) or "Command"/"Apple" (on Mac) key while clicking the nodes.
  3. Click the "Group Selected" icon from the toolbar.
  4. The selected nodes will be shown on the Canvas in one-color area as grouped. You can use the Group pane which will be shown above the Schemas window to:
    • Change the Group Type: Graph, Optional, Union or Construct
    • Set the Group's ID label.



Add Named Graph(s) to the SPARQL query

  1. Click to the Advanced tab.
  2. Click to the Named Graph(s) sub-tab.
  3. In the form, enter a value for Named Graph, and click the Add button.
  4. The number of added Graphs will be shown, right-aligned to the Named Graph(s) sub-tab.



Add statement to the SPARQL query

  1. Go to the Advanced tab.
  2. You can add a statement to the SPARQL Query with
    • the Statement Help drop-down list or
    • the Statement Help button shown right after it.
      1. Click the button "Statement Help".
      2. Click on the desired statement name in the Statement Help window which appears.



Related


Referenced by...