%META:TOPICPARENT{name="InteractiveSparqlQueryBuilderTutorials"}% ---+ Interactive SPARQL Query Builder: Basic Tutorial %TOC% ---++ Creating RDF Instance Data using iSPARQL 1 Go to http://cname/isparql, for ex. http://id.myopenlink.net/isparql 1 The iSPARQL initialization window will be shown: %BR%%BR% %BR%%BR% 1 Finally will be presented the iSPARQL Advanced tab open with a default SPARQL query: SELECT * WHERE {?s ?p ?o} %BR%%BR% %BR%%BR% 1 Go to QBE tab: %BR%%BR% %BR%%BR% 1 Click the Clear Pane icon on the toolbar to empty the Canvas. %BR%%BR% %BR%%BR% %BR%%BR%%BR%%BR% 1 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# 1 As result the Schemas window under "unbound", you should now see the items sioct and sioc. %BR%%BR%%BR%%BR% 1 Now click on the sioct -> Classes -> + icon in order to expand the classes list: %BR%%BR%%BR%%BR% 1 Scroll down the shown list and drag-and-drop the Subject Node Weblog onto the QBE working Canvas. %BR%%BR%%BR%%BR% 1 As result should be created a Subject node of Datatype sioct:Weblog at the point you dropped it. 1 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; 1 Change the Node Variable label value; 1 Set the Node Datatype; 1 Set the visibility property of the variable by hatching the "Visible?" check-box; 1 Set participation in the "Order By" clause bz hatching the "Order By" check-box: %BR%%BR%%BR%%BR% 1 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. %BR%%BR%%BR%%BR% 1 In the Object Node pane, change the type to Literal and change the Variable label value to ?s. %BR%%BR%%BR%%BR% 1 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/ %BR%%BR%%BR%%BR% 1 Drag-and-drop the Class Document item from the Concepts list over the Node with Literal type that we created above. 1 You should now see that the Datatype in the Node pane for the selected node has changed, from Literal to foaf:Document. %BR%%BR%%BR%%BR% 1 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. %BR%%BR%%BR%%BR% 1 You can add more nodes: %BR%%BR%%BR%%BR% 1 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. 1 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. %BR%%BR%%BR%%BR% 1 Enter for Name for ex. sioc:container_of and un-hatch the Visible? check-box. %BR%%BR%%BR%%BR% 1 Click the Connector icon from the QBE toolbar and drag from the ?post node to to the ?maker node. %BR%%BR%%BR%%BR% 1 In the Connector pane, check the Optional? check-box and un-hatch the Visible? check-box. %BR%%BR%%BR%%BR% 1 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. 1 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: %BR%%BR%%BR%%BR% 1 Click the "Connector" icon from the QBE toolbar and drag from the ?maker node to the ?nick node. %BR%%BR%%BR%%BR% 1 In the Connector window hatch the Optional? check-box and un-hatch the Visible? check-box. Enter foaf:nick for Name. %BR%%BR%%BR%%BR% 1 The Final Graph Model can be viewed in the QBE working pane. %BR%%BR%%BR%%BR% ---++ 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 %BR%%BR%%BR%%BR% 1 Click the Run Query button on the QBE toolbar. 1 The query results will be shown in the Results tab. %BR%%BR%%BR%%BR% 1 You can also change dereferencing: * "SPARQL Describe" ( by default ): for selected link of the result set performs describe, for ex. for link "http://id.myopenlink.net/dataspace/Bratsas/weblog/Bratsas%27s%20Weblog": %BR%%BR%%BR%%BR% * "SELECT IRI as S or O": for selected link of the result set performs select IRI as S or O, for ex. for link "http://id.myopenlink.net/dataspace/Bratsas/weblog/Bratsas%27s%20Weblog": %BR%%BR%%BR%%BR% * "GET PAGE": for selected link of the result set performs redirect to this link, for ex. for link "http://id.myopenlink.net/dataspace/Bratsas/weblog/Bratsas%27s%20Weblog": %BR%%BR%%BR%%BR% * "Use Virtuoso Web Service", for selected link of the result set performs Virtuoso Web Service execution, for ex. link for "http://id.myopenlink.net/dataspace/Bratsas/weblog/Bratsas%27s%20Weblog": %BR%%BR%%BR%%BR% 1 View the SPARQL parameters values in the SPARQL Params sub-tab: %BR%%BR%%BR%%BR% 1 View the response values from the Response sub-tab: %BR%%BR%%BR%%BR% 1 View the SPARQL query produced from the graph model you have built from the Query sub-tab: %BR%%BR%%BR%%BR% ---++ Saving the Graph Model 1 Go to QBE tab and click the Save As icon from the QBE toolbar. 1 As result should be shown the WebDAV Browser: %BR%%BR%%BR%%BR% 1 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. %BR%%BR%%BR%%BR% 1 Click "Save". ---++ Generating a SPARQL Query from the Graph Model 1 Go to QBE tab. 1 Click the Generate icon on the toolbar. 1 The Advanced tab will open, with the query generated from your Graph in the SPARQL Query text-area. %BR%%BR%%BR%%BR% 1 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. %BR%%BR%%BR%%BR% 1 Now in the SPARQL Query Working area of the Advanced tab, add a new optional node to the query for foaf:phone. %BR%%BR%%BR%%BR% 1 To apply the query changes to the Graph model, click the "Visualize" button on the Advanced tab toolbar. %BR%%BR%%BR%%BR% ---++ Setting Results Rows 1 Go to the QBE tab. 1 At the bottom of the page change in "Query options" the Resize site limit value, for ex. to 10: %BR%%BR%%BR%%BR% ---++ Adding a dataset 1 On the QBE toolbar, click the Dataset button. 1 Choose Type and enter a Data Source URI value. 1 Click the Add button. %BR%%BR%%BR%%BR% ---++ Other iSPARQL Features ---+++ Auto arrange the Graph Model 1 Go to the QBE tab. %BR%%BR%%BR%%BR% 1 Click the Auto arrange icon on the toolbar. 1 The Graph model layout will be re-arranged to a more compact form. %BR%%BR%%BR%%BR% ---+++ Group selected nodes of the Graph Model 1 Go to the QBE tab. 1 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. 1 Click the "Group Selected" icon from the toolbar. 1 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. %BR%%BR%%BR%%BR% ---+++ Add Named Graph(s) to the SPARQL query 1 Click to the Advanced tab. 1 Click to the Named Graph(s) sub-tab. 1 In the form, enter a value for Named Graph, and click the Add button. 1 The number of added Graphs will be shown, right-aligned to the Named Graph(s) sub-tab. %BR%%BR%%BR%%BR% ---+++ Add statement to the SPARQL query 1 Go to the Advanced tab. 1 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". 1 Click on the desired statement name in the Statement Help window which appears. %BR%%BR%%BR%%BR% ---++ Related * [[InteractiveSparqlQueryBuilderTutorials][iSPARQL Tutorials]] * [[InteractiveSparqlQueryBuilderBasicTutorial1][Basic iSPARQL Tutorial with query built from a blank canvas and pre-typed Nodes]] * [[InteractiveSparqlQueryBuilderBasicTutorial2][Basic iSPARQL Tutorial with query built from a blank canvas and Nodes dragged from the Toolbar]] * [[InteractiveSparqlQueryBuilderQueryTutorialConstruct][iSPARQL Querying Tutorial with SPARQL Query type "CONSTRUCT"]] * [[InteractiveSparqlQueryBuilderQueryTutorialDescribe][iSPARQL Querying Tutorial with SPARQL Query type "DESCRIBE"]] * [[InteractiveSparqlQueryBuilderQueryTutorialDescribeGoogleMapView][iSPARQL Querying Tutorial "DESCRIBE" with Google Maps View Results]] * [[InteractiveSparqlQueryBuilderQueryTutorialInsert][iSPARQL Querying Tutorial with SPARQL Query type "INSERT"]] * [[InteractiveSparqlQueryBuilderQueryTutorialDelete][iSPARQL Querying Tutorial with SPARQL Query type "DELETE"]] * [[InteractiveSparqlQueryBuilderQueryTutorialSlc][iSPARQL Querying Tutorial with SPARQL Query type "SELECT"]] * [[OATWikiWebIndex][OpenLink AJAX Toolkit (OAT)]] CategorySPARQL CategoryRDF CategoryOpenSource CategoryOAT CategoryTutorial CategoryDocumentation