190 likes | 294 Views
Stack-Based Approach and Stack-Based Query Language - Overview. Presentation prepared for the OMG Analysis & Design Task Force (ADTF) OMG TECHNICAL MEETING, Brussels, Belgium June 25th-29th, 2007 by Prof . Kazimierz Subieta
E N D
Stack-Based Approach and Stack-Based Query Language- Overview Presentation prepared for the OMG Analysis & Design Task Force (ADTF) OMG TECHNICAL MEETING, Brussels, BelgiumJune 25th-29th, 2007 by Prof. Kazimierz Subieta Polish-Japanese Institute of Information Technology, Warsaw, Poland subieta@pjwstk.edu.pl http://www.ipipan.waw.pl/~subieta SBA/SBQL pages:http://www.sbql.pl
Topics • What is SBA? • What is SBQL? • SBA/SBQL database models • Abstract implementation as semantic specification • The idea of SBA • Naming, scoping, binding and environment stack • SBA/SBQL data store models • SBA/SBQL in recent (pending) projects • ODRA architecture • SBQL queries and programs (examples) • Unique qualities of SBA/SBQL
What is SBA? • The Stack-Based Approach (SBA) is a formal methodology addressing object-orientedquery and programming languages. • In SBA we reconstruct query languages’ concepts from the point of view of programming languages (PLs). • 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, views, etc.
What is SBQL? • SBQL (Stack-Based Query Language) plays the same role for object models as the relational algebra for the relational model. • However: • SBQL is incomparably more powerful - this concerns universality of data models and complete algorithmic power. • SBQL is much more powerful than OQL, OCL and XQuery (at least concerning o-o data model, updating capabilities, program control facilities, programming abstractions and virtual o-o views). • SBQL is fully precise w.r.t. the specification of semantics. • SBQL (in contrast to SQL and OCL) is free of parasite syntax. • SBQL has been carefully designed from the pragmatic point of view. • SBQL is strongly (statically) and semi-strongly typed. • SBQL has advanced query optimization methods.
Pragmatic quality of SBQL • It 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 (procedures, functions, modules, types, classes, methods, views, etc.), • Clean formal semantics, • No semantic reefs, • No far context dependencies, • Following commonly accepted programming languages’ principles.
SBA/SBQL database models • SBA and SBQL are neutral to database models. • SBA covers all database models that we are aware of: • Relational and nested-relational models, • XML and RDF models, • Object-oriented models with static (UML-like) and dynamic inheritance, • Collections, associations, encapsulation, polymorphism, etc. • SBA and SBQL address data structures rather than data models. • When a concept in a data model is mapped as an abstract data structure, a corresponding feature of SBQL can handle it. • SBQL is the first and only query language that deals with dynamic object roles and dynamic inheritance.
Abstract implementation as semantic specification • It is a kind of operational semantics based on abstract data structures that participate in query/program processing • SBA introduces three well-known structures: • object store, • environment stack (thus Stack-Based Approach), • query result stack. • These structures are fundamental for precise semantic description of everything that may happen in database query/programming languages. • Classical query operators, such as selection, projection, joins and quantifiers, can be generally and precisely specified. • We abandon (poor) database theories such as object algebras or calculi.
The idea of SBA • The SBA solution relies on adopting a run-time mechanism of PLs and introducing necessary improvements to it. • The main syntactic decision is the unification of PL expressions and queries - no conceptual difference: • 2+2 • (x+y)*z • Employeewhere salary = 1000 • (Employeewhere salary = (x+y)*z).surname • All such expressions/queries can be used as: • arguments of imperative statements, • parameters of procedures, functions or methods • a return from a functional procedure (from a method).
Naming, scoping, binding and environment stack • Each name occurring in a query is bound to run-time programming entities (persistent data, procedures, actual parameters of procedures, local procedure objects, etc.), according to the actual scope for the name. • The common PLs’ approach is that the scopes are organized in an environment stack with the “search from the top” rule. • Some extensions to the structure of stacks used in PLs are necessary. • Abstract implementation of query operators, imperative programming constructs and procedures (functions, methods, views, etc.) is defined in terms of the mentioned abstract structures: • object store, • environment stack, • query result stack
SBA/SBQL data store models • SBA/SBQL assumes a family of formal object store models which are enumerated M0, M1, M2 and M3. • The simplest is M0, which covers relational, nested-relational and XML-oriented databases. • M0 assumes hierarchical objects with no limitations concerning the nesting of objects and collections. M0 also covers pointer links (relationships) between objects. • M1 store model extends M0 by classes and static (multiple) inheritance. • M2 store model extends M1 by object roles and dynamic inheritance. • M3 store model extends M1 or M2 by encapsulation.
SBA/SBQL in recent (pending) projects • ODRA (Object Database for Rapid Applications) - queries, imperative constructs, programming abstractions, classes, types, methods, inheritance, modules, query optimization,... • European project eGov Bus. Integrating distributed resources being under control of various European governmental institutions. • SBQL as an embedded QL for application programming in Java. • SBQL as self-contained DBPL for application programming. • Virtual repository based on SBQL virtual updateable OO views • European project VIDE - developing a visual programming language for the OMG MDA. • OCL and other concepts related to Executable UML are implemented • XML2XML mapper based on SBQL
SBQL queries • Get all information on departments for employees named Doe: (EmpwherelName = “Doe”).worksIn.Dept • Get the name of Doe’s boss: (EmpwherelName = “Doe”).worksIn.Dept.boss.Emp.lName • Names and cities of employees working in departments managed by Kim: (Deptwhere (boss.Emp.lName) = “Kim”).employs.Emp. (lName, ifexists(address) thenaddress.cityelse “No address”) • For each employee get the name and the percent of the annual budget of his/her department that is consumed by his/her monthly salary: Emp . (lNameasn, (((ifexists(sal) thensalelse 0) ass). ((s * 12 * 100)/(worksIn.Dept.budget)) aspercentOfBudget)
SBQL programs • For each person having no salary give the minimal salary in his/her department: for each (Empwhere notexists(sal)) asedo { e.changeSal( min(e.works_in.Dept.employs.Emp.sal) )} • A method: changeSal(newSal: real): boolean {if (not exists(self.sal))then{ sal: real[0..1];self :< createsal(newSal); } else {if (self.sal > newSal) thenreturn false;else self.sal := newSal; }return true; }
Conclusions • To make a high quality standard for object-oriented databases, the specification of semantics is the must, … • …to avoid the fate of SQL-99 and ODMG standards, perceived as loose recommendations rather than technical specifications. • SBA offers the unique method of query languages’ construction and semantic specification. • SBA is a holistic database theory, it doesn’t give up any (even the most advanced) feature of current practical O-O database QL/PL. • Michi Henning, ZeroC: „No standard should be approved without a reference implementation. • This provides a first-line sanity check of what is being standardized. • No one is brilliant enough to look at a specification and be certain that it does not contain hidden flaws without actually implementing it.” • SBQL has been implemented more than 10 times, for different systems and purposes.
10 unique qualities of SBA/SBQL for a new O-O database standard • Orthogonal syntax, full compositionality of queries. • Universal formal semantics based on abstract implementation. • Computational universality, advanced data structures, integration with PL constructs. • Strong typing of advanced O-O queries and programs. • Several advanced implementations, next are pending. • Fully transparent O-O virtual updatable views. • Strong potential for query optimization. • All O-O notions treated formally and uniformly. • Sound and manageable metamodel. • The potential for distributed query processing.
Acknowledgement • This work is supported by the European Commission 6-th Framework Programme, Project VIDE - VIsualize all moDel drivEn programming, IST 033606 STP • VIDE Participant List (in random order) • SAP AG (Germany) • SOFTEAM (France) • Institute for Information Systems at the German Research Center for Artificial Intelligence (Germany) • IESE Fraunhofer (Germany) • Polish-Japanese Institute for Information Technology (Poland, coordinator) • FIRST Fraunhofer (Germany) • TNM Software GmbH (Germany) • Bournemouth University (United Kingdom) • Rodan Systems S.A. (Poland) • ALTEC (Greece)