Skip to main content
Fig. 3 | Journal of Cheminformatics

Fig. 3

From: Advanced SPARQL querying in small molecule databases

Fig. 3

Example of variable consistency check. This example demonstrates the work of the variable consistency checking algorithm. Part a shows a simple SPARQL query intended to select resources that belong to the :Dog class or to the :Bird class and also belong to the :Mammal class. The query has a solution in standard animal ontology. However, the second alternative of the union pattern is inconsistent with the rest of the query (because birds are not mammals). Therefore, this alternative has no influence on the final result, and the user should be warned. Before checking, the query is transformed into a syntax tree by the parser. The relevant part of the parser tree is shown in Part b. For better clarity, nodes are identified by numbers. The tree is then processed by the checking algorithm from the leaves to the root. For each node, the class registry and the location registry are computed. Contents of the registries are shown in boxes in Part c. The top part of each box contains the class registry, and the bottom part of the box contains the location registry. A green arrow indicates for which node registries were computed. Triple patterns 4, 6, and 7 simply denote requested classes of variable X, and this information is written into their registries. Group patterns 3 and 5 contain only one child pattern, so their registries are the same as registries of these child patterns. After that, union pattern 2 merges information from group patterns 3 and 5. Finally, group pattern 1 is processed. This pattern contains two child patterns, so the checking phase has to be performed. The location registry of node 7 is compared with the class registry of node 2. Class :Mammal is consistent (is not disjoint) with the union of :Dog and :Bird classes; thus, this part is correct. And vice versa, the location registry of node 2 is compared with the class registry of node 7. Class :Dog is consistent with :Mammal, but class :Bird is not consistent with :Mammal. Therefore, the warning is generated for variable X used on line 10

Back to article page