proposed, based on intensional (E-R diagram: GUIDE [34], GORDAS [20, 19], QBD* ..... ACM SIGACT-SIPLAN Symposium on Principles of Programming ...
On the Expressive Power of Graphical Query Languages1 T. Catarci Dipartimento di Informatica e Sistemistica - Universita' di Roma "La Sapienza" Via Salaria, 113 - 00198 Roma, Italia
Abstract In this paper a comparison is presented between the expressive power of generic graphical mechanisms and the various classes of queries (first-order, fixpoint, programming). A precise evaluation of the expressive power of the languages based on such mechanisms (i.e.purely graphical query languages) is shown. Moreover, an informal analysis is provided relatively to the more general class of the visual query languages, supporting also iconic interaction.
1. INTRODUCTION An important design issue in databases is to find an efficient and intuitively appealing query language which allows for expressing all the computable queries (see [23]). It is a well known fact that the graphics represents a friendly mechanism for the humancomputer interaction. In these years, many graphical query languages have been proposed, based on intensional (E-R diagram: GUIDE [34], GORDAS [20, 19], QBD* [7, 4], Pasta-3 [24], etc.) or extensional (instances graphs: G+[15, 16, 17], etc.) data models. Recently some proposal deals with object-oriented models, graphically represented by a structure resembling a semantic network (OQL [1], etc.), which allow different classes of queries to be expressed. At the present state of the art, a crucial question is: "Does a purely graphical language allow the user to express all the computable queries?" The main goal of this paper is to provide an answer to such a question, by comparing the graphical query mechanisms with the various classes of queries (first-order, fixpoint, programming). A pre-requisite to this work is giving the definition of the terms "purely 1 Research supported by National Research Council (CNR) Italy, Progetto Finalizzato Sistemi Informatici e Calcolo Parallelo, Sottoprogetto 6, Tema INFOKIT, and by EEC, under the ESPRIT Project 5638 "KIM".
graphical language", and correctly placing the graphical languages in the wider area of the visual languages. The paper is organized as follows. In Section 2 we define a "purely graphical language". In Section 3 we present a formalism for expressing the first-order queries. In Section 4 we discuss how the fixpoint queries can be formulated in terms of a graphical approach. In Section 5 we deal with the class of programming queries. Finally, conclusions are drawn in Section 6.
2. PURELY GRAPHICAL LANGUAGES In this section we first define a general graphical structure and we introduce the notion of graphical operation in an abstract sense. The graphical structure is intended to represent the underlying data (independently on a specific data model) on which graphical operations are performed. Such a structure and the graphical operations are defined as follows: Def. Graphical Data Structure (GDS) A GDS is a pair , where L is a set of labelnodes (i.e. nodes with a label), and H is a set of oriented hyperarcs hx,Y (i.e. hx,Y links a single source labelnode x to a set of several labelnodes Y). Def. Graphical Operation (GP) A GP is an operation performed on a GDS, S = , giving as result a new GDS, S' = . Such an operation consists of either clipping a subgraph of S (in this case L' ⊆ L and H' ⊆ H), or drawing a single hyperarc between disconneted nodes (in this case S' = ). The basic idea of this paper is to show that an invariant graphical structure (i.e. the GDS) may be used in a way such that augmenting the level of extensionality of the represented data, the expressive power of the GPs grows. Moreover, we show that due to the simplicity of GPs, one cannot express complex queries, such as the transitive closure. Indeed, for this purpose we need more powerful graphical mechanisms, such as icons. Notice, however, that icons make us leaving the field of graphical languages, and enter in the more general class of the visual languages [12]. Generally speaking, different parameters of a visual query language (VQL) exist, concerning the kinds of representation and the kinds of operations on them. The visual representation may be: a) more abstract, showing mainly spatial relations; b) more concrete, using necessarily metaphors to describe the semantics of the system components; c) a combination of the two. These different kinds of representation are generally translated into a) diagrams; b) icons; c) a combination of the two. Operations are defined by pointing at the objects representing the database arranged in space, and initiating an action by a special clicking event. Clicked objects will then change parameters as color and shape, or may be "dragged" around (this means the implementation of some kind of animation). Those graphical events have to be clearly and consistently related to the system operation semantics.
In order to define the expressive power of GPs we first need to associate a precise semantics to the GDS. There are two main interpretations of a GDS, intensional and extensional, which are discussed in the following sub-sections. 2.1 Intensional Interpretation of a GDS In this case a GDS is used for describing the classes of interest and the relationships among them, without any concern to the actual values of the database. In particular, in the intensional representation of a GDS (IGDS) the labelnodes represent classes (i.e. collections of entities with the same properties, where the term entity refers to a distinguishable thing in the described world) and relationships, which are ordered lists of classes (fig. 2.1). It is worth noting that such an IGDS may partially represent semantic models, such as the Entity-Relationship Model [14], or the Functional Model [30].
IN
CITY
CONNECTS
STREET
IS CONNECTED
BUILDING
Fig. 2.1: An example of IGDS With regard to the expressive power of the GPs applied on IGDS, notice that there is no way, with this representation, of asking graphical queries about properties of a single entity. In other words, the GPs allow only the browsing of the data schema, extracting the portion of interest. Therefore, if we consider the "select-project" queries (e.g. the "sargable" queries in system R [29]) as the lowest level in the query hierarchy [9], using both GPs on IGDS we cannot express neither such queries. The expressive power of GPs enhances if the IGDS is extended by introducing labelnodes representing properties of the classes (attributes). An attribute associates a value from a given domain with each entity in a class. With such an extension, the IGDS may represent both semantics models, and traditional models (relational, hierarchical, network). For instance, in Fig.2.2 the IGDS of Fig.2.1 is extended by introducing some properties of both the class Building (e.g. the address and the period in which the building has been erected, called age in the figure) and the class Street (e.g. the number and the kind of the street, commercial, exclusive, etc.). In the rest of this paper we are especially interested in the relational interpretation of a GDS. In this case, relation schemas are modeled by means of hyperpaths. Formally, we define an hyperpath hp x,Y between a source node x (x ∈ L) and a nonempty set of labelnodes Y (Y ⊆ L) as a set of hyperarcs such that: if x ∈ Y then hpx,Y = º; if x ∉ Y then ¡ X' ⊆ L, ¡ x'∈ X', such that ¡ h x,X' ∈ hp x,Y and ¡ hp x',Y ⊂ hp x,Y .
When attributes are considered in IGDS, the GPs allows the browsing of part of the database schema, or part of a single relation schema, so producing the same result of the projection operator in relational algebra. Thus, we are near to obtain the "select-project" queries.
CONNECTS IS CONNECTED KIND
ADDRESS
NUMBER
AGE
STREET
BUILDING
Fig. 2.2: An example of IGDS with labelnodes representing properties 2. 2 Extensional Interpretation of GDS In an extensional GDS (EGDS) we represent both the intensional and the extensional part of the database. Indeed, a part of the labelnodes contains values belonging to the active domain of the database. For example, in figure fig.2.3 there is only one instance of the class Building, with address = xyz and age = 1800; while there are two instances of the class Street, with number = 500, kind = commercial, and number = 1000, kind = exclusive, respectively. Moreover, the instance of Building is linked with the instance of Street having number 500 by the relationship Connects. Therefore, the set of labelnodes is partitioned into three subsets, according to their semantics, as follows (recall that we are referring to the relational model): 1) a set LR of relation names; 2) a set LA of attribute names; 3) a set LD of value names; With extensional values in the GDS, the class of queries expressible by GPs substantially grows. More precisely, we will show in the next section that the the class of queries computed by the GPs contains the class of queries computable by the Relational Algebra [32]. In order to prove this fact we need to introduce a precise mapping between the EGDS and the Relational Model. Such a mapping h (h-1 is the inverse) is defined as follows: - if n belongs to LR then h()=n, where n is a relation name; - if n belongs to LD then h()=n, where n is a value of a domain; - if n belongs to LA then h()=n, where n is an attribute name; - if n belong to LR and N={a1..ak}∈LA, then h()=S, where S is a relation schema with name n and attribute names a1..ak;
- if n belongs to LD and D={d1..dk}∈L D , then h ()=T, where T is the tuple ; - if n belongs to LR and D={d1..dk}∈L D , then h ()=R, where R is a relation with name n, consisting of all the tuples with values in D. -1
It is easy to show that, if R is a relation with name n, h (R) = G = , where G is an extensional GDS with LR = {n}, LA equal to the set of attribute names of R, and LD equal to the values of the tuples of R. Moreover, H is equal to the set of hyperarcs in hpn,L . Analogous considerations can be made for more complex relational schemas. D EXCLUSIVE
1000
Legenda
COMMERCIAL CONNECTS
500
n belongs to LR n belongs to LA
KIND
XYZ
STREET
NUMBER
ADDRESS
AGE
n belongs to LD
BUILDING
1800
Fig.2.3: An example of EGDS
3. GPs and FIRST-ORDER QUERIES In the following we discuss on the expressive power of the GPs performed on an EGDS, and we prove that the class of queries computed by the GPs (denoted as Q(GP)) contains the class of queries computable by the Relational Algebra (denoted as Q(-,∪, ×, ΠA, σF) see [32]). Theorem 1 Q(-,∪, ×, ΠA, σF) ⊆ Q(GP). Proof The theorem is an easy induction on the size of the algebraic expression. Formally, we show that if an expression has i occurrences of operators, then there is a GP that produces the value of the expression.
The basis is i=0, that is a single operand. If this operand is a given relation, say R, then, by definition, we can select an EGDS G such that h (G)=R. The only other possibility is that the operand is a set of tuples, this is a trivial case too. For the induction, consider an expression whose outermost operator is one of union, difference, projection, selection, and product. Case 1: The expression is E=E1∪E 2. Then by the inductive hypothesis, there are EGDS G1 and G2 such that h(G1)=E1 and h(G2)=E2. The arities of the relations defined by the expressions E1 and E2 must be the same or the union operator cannot be applied. Notice that this constrains the lenght of some hyperarc in G 1 and G2. More precisely, if g1(resp. g2) is the node corresponding to the name of the relation E1 (resp. E2), Lenght1 is the lenght of the hyperarc hg1,LA1 with source node g1 (LA1 being the set of attribute names in G1), Lenght2 is the lenght of the hyperarc hg2,LA2 with source node g2 (LA2 being the set of attribute names in G2), then Lenght1 must be equal to Lenght2. Under this condition, it holds that h(GP(G1∪G2))=E. Case 2: The expression is E=E1-E2. Following the same reasoning line as in case 1, we have: h(GP(G1-G2))=E. Case 3: E=ΠA(E1). By the inductive hypothesis we have h(G1)=E1. Let N be a set of labelnodes: N= {n | n ∈ h-1(A) ∧ n ∈ G1}. It is easy to see that h(GP(N))=E. Case 4: E=σF(E1). By the inductive hypothesis we have h(G1)=E1. Let N be a set of labelnodes: N= {n | n ∈ LD ∧ n ∈ G1 ∧ F(n)=T}, then h(GP(N))=E. Case 5: E=E1×E2. By the inductive hypothesis we have h(G1)=E1, h(G2)=E2. Let g1(resp. g2) be the node corresponding to the name of the relation E 1 (resp. E2), i.e. the set LR of G1 (resp. G2) is {g1}(resp. {g2}); let N1 and N2 be two sets of nodes such that N1= {n | n ∈ LD ∧ ¡ hpg1,N1 in G1}; N2= {n | n ∈ LD ∧ ¡ hpg2,N2 in G2}. Let GP(G 1)°GP(G 2) denote the GDS obtained from G1 and G2 by drawing an hyperarc from each node n1∈ N1 such that : h-1(T1)= to each node n2∈ N2 such that h-1(T2)=, where T1 is a tuple of h(G1) and T2 is a tuple of h(G2), and
drawing an hyperarc from each node n 2∈ N 2 to each node n1∈ N 1 under the same conditions. Now, it is easy to see that h(GP(G1)°GP(G2))=E. QED The above results show that, the expressive power of a generic graphical language (without any kind of textual interaction) grows according to the wider semantics of the structure representing the underlyining data. If we restrict the visual query mechanisms to the above GPs, the upper bound of the expressive power is represented by the first-order queries, as stated in the following theorem. Theorem 2
h(G)=R (where R is a binary relation) there is no graphical operation GP giving as result a new EGDS G' such that h(GP(G'))=R+, the For an arbitrary EGDS G such that
transitive closure of R. Proof For the sake of brevity, the proof is omitted. The general lines of the proof follow the analogous one for the Relational Algebra, shown into [2].
4. GPs and FIXPOINT QUERIES The following step in order to improve the expressive power of the GPs, is adding another visual mechanism, namely icons. A large literature concerns the icon semantics (see for example [12, 13]). Following Chang [13] we introduce the concept of generalized icon, abstracting both object icon and process icon. An object icon is a two-part representation of an object, written as (X m, Xi). Xm is the logical part (the meaning) and Xi is the physical part (the image). Objects wich are generally dealt with in databases have visual meaning, but no visual image: (Xm, e), with e denoting a null object. When a visual representation of the objects is adopted, we transform (X m , e) into (Xm , X'm ) for some graphical symbol X' m , so that it can be visualized. Similarly, a process icon represents an action, or a computational process. Languages constructs handled by a VQL are process icons, or icons with a logical and a physical part that represent a computational process. The distinction between an object icon and a process icon depends both on context and on interpretation. For example, the road sign of a diagonal line inside a circle can be interpreted as a stop sign by a computer vision system, in which case it is an object icon. But the same sign could be interpreted as a halt command by a mobile robot, in which case it is a process (action) icon. By using both object and process icons we can build iconic sentences. Iconic sentences are iconic structures formed according to specific linguistic rules. An iconic sentence has definite syntactic rules governing its construction and definite semantic rules governing its interpretation. An iconic language is composed of these iconic sentences. The syntactic analysis of an iconic language is the analysis of the visual sentences to determine the underlying syntactic structure. The semantic analysis is the interpretation of a visual sentence to determine its meaning. It is worth noting that iconic languages have an obvious drawback in the choice of the set of icons to be used. In fact, some icons are inherently ambiguos and other can only be interpreted within a certain context. Moreover, there is no universally accepted set of icons, as well as there is no set of icons representing the information content of the whole reality. So, in order to build complex icons starting from a set of basic ones, it is necessary to carefully define the minimal suitable set of icons and some compositional law. In the following we show how icons allow us to enlarge Q(GP), so as to include the class of fixpoint queries. Fixpoint queries (see [10]), are obtained by augmenting the standard relational algebra (or the standard first order operators) with fixpoints. All
fixpoint queries can be expressed by taking a single fixpoint on a first order formula (followed by some simple first order operation) (see [21, 22]). In other words, it is not necessary to take fixpoints more than once in order to express all the fixpoint queries. It is worth noting that other querying paradigms have been explored, in order to improve the expressive power of the relational algebra. For example, Horn clause queries (see [11]) have been introduced, but they cannot express all the first order queries [9], although they can express some fixpoint, such as transitive closure. An extension of the Horn clause queries are the stratified queries [11, 27, 33]. Stratified queries can express all the first order queries, but they cannot express all fixpoints. Therefore, we concentrate precisely on fixpoint queries. We can graphically express fixpoint queries with a very simple mechanism, that is adding to the previously defined structures an icon representing the operation of least fixpoint. Such an icon, that is a static object icon, may be graphically presented as a spiral, or something other representing the idea of loop. Notice that, with icons, we can no longer give a universal representation for the objects, because each icon represent a precise object, and it has always a subjective (or at least conventional) meaning. Moreover, as in our case, the icon is semantically overloaded, and its friendliness is questionable. On the other hand, it does not seem possible to express with purely graphical interactions complex operations, such as fixpoint, or more generally loop, and the iconic solution seems to be, at the present state of the art, the best for the final user.
5. GPs and PROGRAMMING QUERIES One of the features which is missing from the fixpoint queries (not the only one) is that of counting. For instance, fixpoint queries cannot tell if the size of a relation is even or odd: if the database A contains no relations other than the domain D, then the following query "EVEN" is not a fixpoint query [10]: EVEN = True if |D| is even, False otherwise. In order to compute the query EVEN we consider a first class of programming queries, namely the "Bounded-Loop Queries" [8]. In such queries a looping statement is added to the basic constructs, that is: For all tuples t in relation S do Body od where S is a variable and the body is executed for each tuple t in S. Moreover, the order in which the tuples are selected is not important. The bounded-loop queries are all computable in polynomial time and are strictly more expressive than the fixpoint queries. For example the query EVEN may be expressed as [9]: EVEN ←True For |S| do EVEN← ¬EVEN od Bounded-loop queries may be graphically expressed by using the same loop icon introduced above, and defining dynamic graphs, i.e. graphs changing their shape during the computation. Dynamic graphs play the same role of dynamic icons (see [31]), i.e.
icons with a variable interpretation, that may be either time sequenced or modified by the user. In the query EVEN we may introduce a dynamic graph consisting of a single node with label domain True/False. The query may be expressed in the following way: - selecting the loop icon; - selecting the nodes representing the instances of the relation S; - building the dynamic graph. We assume that when the body of the loop is reduced to the selection of a dynamic variable, without any other operation, the computation of the loop itself is reduced to the changes of label of the variable. The label may either alternatively assume the values of its domain (boolean variables) or assume sequential values (counter variable). Unfortunately, the class of bounded-loop queries is not equal to the class of computable queries [9]. Indeed, [8] it is shown that for computing all the computable queries, we need : a) generic variables, not ranked, whose values at any point in the computation are relations of some rank; b) the equality relation {(d,d) | d∈ D}; c) the loop operator: if P is a statement, then the following is also a statement: While X={} do P od. This loop condition is different from the one above, where a simple expression is to be repeated a fixed number of times. On the contrary, in the present case we need to express the condition regulating the end of the loop. Equality is also necessary, and may be easily modeled as hypergraph isomorphism. We have not found in the literature any language proposal trying to visually express such a general class of queries. It is our opinion that a promising approach is to use dynamic graphs in order to represent both the end condition and the body of the loop. However, it is out the aim of this paper to evaluate the possibility of such a graphical approach, and to compare the resulting class of the queries with the class of computable queries.
6. CONCLUSIONS In this paper an analysis of the expressive power of the graphical query languages has been proposed. It has been proved that, as the class Q(GP) is equal to the class of firstorder queries, the level of the expressive power may depend only on the level of extensionality of the data model, and be invariant with respect to the graphical operations. Trying to augment Q(GP) results in changing the graphical mechanisms (i.e. the GPs), introducing icons and dynamic graphs. This make us leaving the field of graphical query languages, entering in the more general class of visual query languages. While a formal characterization has been provided for comparing the Q(GP) and the first-order queries, open problems remain both the definition and the formal characterization of graphical mechanisms for expressing the computable queries.
7. REFERENCES [1]
A.M. Alashqur, S.Y.W. Su, H.Lam, M.S. Guo, E.Barkemeyer - OQL - An Object-Oriented Query Language - Technical Report, University of Florida, 1988.
[2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]
[19] [20] [21] [22] [23]
A.V.Aho, J.D.Ullman - Universality of Data Retrieval Language - Proc. of the 6th ACM SIGACT-SIPLAN Symposium on Principles of Programming Languages, pp. 110-120, 1979. M.Angelaccio, T.Catarci, G.Santucci - QBD*: A Graphical Query Language with Recursion - to appear in IEEE Transactions on Software Engineering, October 1990. M.Angelaccio, T.Catarci, G.Santucci - QBD*: A Graphical Query Language Proc. of the 3rd Human-Computer Interaction Conference, Boston, 1989. M.Angelaccio, T.Catarci, G.Santucci - QBD*: A Fully Visual Query System - to appear in Vol. 1, No. 2 of Journal on Visual Languages and Computing. H.Boley - Directed Recursive Labelnode Hypergraphs: A New Representation Language - Artificial Intelligence, 9, pp.49-85, 1977. T.Catarci, G.Santucci - QBD: A Graphic Query System - Proc. of the 7th EntityRelationship Conference, Rome, November 1988. A.K.Chandra - Programming Primitives for Database Languages - Proc. of the 8th ACM Symp. on Principles of Database Systems, pp.50-62, 1981. A.K.Chandra - Theory of Database Queries - Proc. Symp. Principles of Database Systems, 1988. A.K.Chandra, D.Harel - Structure and Complexity of Relational Queries - Journal of Computer Sciences, N.25, 1, pp.99-128, August 1982. A.K.Chandra, D.Harel - Horn Clause Queries and Generalizations - Journal Logic Programming, Vol 1, N.1, pp.1-15, 1985. Visual Languages - S.K.Chang (ed.), Plenum Publishing, New York, 1986. S.K.Chang, G.Tortora, B.Yu, A.Guercio - Icon Purity - Toward a Formal Theory of Icons - International Journal of Pattern Recognition and Artificial Intelligence, Vol.1, N.3&4, pp. 377-392, 1987. P.P.Chen - The Entity-Relationship Model toward a Unified View of Data - ACM Transactions on Data Base Systems, 1976. I.F.Cruz - Domains of Application for the G+ Query Language - Technical Report CSRI-212, Computer Systems Research Institute, University of Toronto, September 1988. I.F.Cruz, A.O.Mendelzon, P.T.Wood - A Graphical Query Language Supporting Recursion - Proc. ACM SIGMOD Conf. on Management of Data, 1987. I.F.Cruz, A.O.Mendelzon, P.T.Wood - G+: Recursive Queries Without Recursion - Proc. of the 2nd International Conference on Expert Database Systems, pp. 355368, April 1988. B.Czejdo, D.W.Embley - An approach to computation specification for an entity-relationship query language - S.March (ed.) Proc. of the 6th International Conference on Entity-Relationship Approach, New York, pp.307322, 1987. R.Elmasri, J.A.Larson - A Graphical Query Facility for ER Databases Proc. of the 4th International Conference on Entity-Relationship Approach, Chicago, Illinois, pp. 236-245, 1985. R.Elmasri, G.Wiederhold - GORDAS : a formal high-level query language for the entity-relationship model - Proc. of the 2nd International Conference on Entity-Relationship Approach, Washington, D.C., pp. 49-72, 1981. Y.Gurevich, S.Shelah - Fixed-point Extensions of First-Order Logic - Annals of Pure and Applied Logic 32, North Holland, pp. 265-280, 1986. N.Immerman - Relational Queries Computable in Polynomial Time - Information and Control, 68, pp. 86-104, 1986. M.Jarke, Y.Vassiliou - A Framework for Choosing a Database Query Language ACM Computing Surveys, Vol.17, 3, 1985, pp. 313-340.
[24] M.Kuntz, R.Melchert - Pasta-3's Graphical Query Language: Direct Manipulation, Cooperative Queries, Full Expressive Power - Proc. of the 5th Int. Conf. on Very Large Database, Amsterdam, August 1989. [25] V.M.Markowitz - ERROL : an entity-relationship role oriented query language - Proc. of the 3rd Conference on Entity-Relationship Approach, 1983. [26] H.M.Markowitz, A.Malhotra, D.P.Pazel - The ER and EAS Formalism for System Modeling, and the EAS-E Language - P.P. Chen (ed.) Entity Relationship Approach to Information Modeling and Analysis, ER Institute, pp. 29-47, 1981. [27] S.Naqvi - A Logic for Negation in Database System - Proc. Workshop on Logic in Databases, 1986. [28] T.R.Rogers, R.G.G.Cattell - Entity-Relationship Database User Interfaces S.March (ed.) Proc. of the 6th International Conference on Entity-Relationship Approach, New York, pp.323-336, 1987. [29] P.G.Selinger, M.M.Astrahan, D.D.Chamberlin, R.A.Lorie, T.G.Price - Access Path Selection in a Relational Database Management System - Proc. ACM SIGMOD Conf., June 1979. [30] D.W.Shipman - The Functional Data Model and the Data Language DAPLEX ACM Trans. on Database Systems, Vol.6, N.1, pp. 140-173, 1981. [31] Y.Tonomura, S.Abe - Content Oriented Visual Interface Using Video Icons for Visual Database Systems - Proc. of the Int. Workshop on Visual Languages, Rome, 1989. [32] J.D.Ullman - Principles of Database and Knowledge-Base Systems - vol. I, 1987. [33] A.Van Gelder - Negation as Failure Using Tight Derivations for General Logic Programs - Proc. of the 3rd IEEE Symp. on Logic Programming, pp.127-139, 1986. [34] H.K.T.Wong, I.Kuo - GUIDE : Graphical User Interface for Database Exploration - Proc. of the 8th VLDB Conference, Mexico City, pp. 22-31, 1982. [35] Z.Q.Zhang, A.O.Mendelzon - A Graphical Query Language for EntityRelationship Databases - Proc. of 3rd International Conference on EntityRelationship Approach, 1983.