Query Language Construction (original) (raw)
The book presents the Stack-Based Approach (SBA) which is a formal methodology addressing database query and programming languages. In SBA we reconstruct query languages' concepts from the point of view of programming languages (PL). The approach is motivated by our belief that there is no definite border line between querying and programming; thus there should be a universal theory that uniformly covers both aspects. SBA offers a unified and universal conceptual and semantic basis for queries and programs involving queries, including programming abstractions such as procedures, functions, classes, types, methods and views. SBA assumes a semantic specification method that is referred to as abstract implementation. It is a kind of operational semantics where one has to determine precisely on an abstract level all the data structures that participate in query/program processing, and then, to specify the semantics of all the languages' operators in terms of actions on these structures. SBA introduces three such structures that are well-known in the specification of PLs: (1) an object store, (2) an environment stack, (3) a query result stack (thus the stack-based approach). These structures are fundamental for precise semantic description of everything that may happen in database query/programming languages. In particular, classical query operators, such as selection, projection, joins and quantifiers, can be generally and precisely specified using the above abstract structures, with no references to classical database theories such as relational/object algebras or calculi. SBA introduces a model query and programming language Stack-Based Query Language (SBQL). It plays the same role as the relational algebra for the relational model, but SBQL is incomparably more powerful. The power of SBQL concerns a wide spectrum of data structures that is able to serve and complete algorithmic power of querying and manipulation capabilities. At the same time, SBQL is fully precise with respect to the specification of semantics. SBQL has been carefully designed from the pragmatic (practical) point of view. We were struggling severely with parasite syntactic sugar, redundant operators and semantic reefs (when human intuitive semantics does not match machine semantics). The pragmatic quality of SBQL is achieved by orthogonality of introduced data/object constructors, orthogonality of all the language constructs, object relativism, orthogonal persistence, typing safety, introducing all the classical and some new programming abstractions and following commonly accepted programming languages' principles. SBA and SBQL are neutral to database models. SBA covers all the database models that we are aware of, starting from the relational model, through XML-oriented data model, RDF-oriented data model, up to sophisticated object-oriented models with static and dynamic inheritance, collections, associations, polymorphism, etc. Our fundamental assumption is that SBA and SBQL address data structures rather than data models. Once we determine how particular concepts in a data model are to be mapped as abstract data structures, we can propose a corresponding SBQL variant that will be able to handle these structures with full algorithmic universality and precision. In this way we have shifted the discussion of query language to another level: we can talk about how particular features of data structures are to be served by SBQL rather than sticking to a concrete query language with a concrete data model. For instance, when we determine how XML files are to be mapped as abstract data structures, we can propose an SBQL variant to address them. In this way, we achieve a unique universality, flexibility and performance optimization potential. In particular, SBQL is the first and only query language that deals with dynamic object roles and dynamic inheritance. Moreover, powerful query optimization methods that are developed for SBQL are prepared to work with such advanced features. This book is a specification of the SBA theory and the SBQL language. It contains general observations on syntax, semantics and pragmatics of query and programming languages for objectoriented database models. General assumptions for the SBQL semantics are also presented. Then, the book deals with abstract object store models as main components of the concept of state, in particular: AS0 store model (complex objects and pointer links), AS1 store model (classes, methods and inheritance), AS2 store model (dynamic object roles and dynamic inheritance) and AS3 store model (encapsulation and information hiding). In the following the environment stack (ENVS), query results and query result stack (QRES) and the function nested are introduced. These concepts form the formal basis for SBQL semantics which is defined in the operational style through abstract implementation. The core of the semantics are so-called non-algebraic operators (selection, projection, navigation, join, quantifiers, etc.), which remain algebraic operators from the relational algebra, but their general