% File: handout.tex
% Date: 21.9.1992
% Author: FM
% Subject: FIDE DBPL / Tycoon demo

\documentstyle[11pt,a4,epsf]{article}

\newcommand{\e}[1]{{\em #1\/}}
\newcommand{\k}[1]{{\sl #1\/}}
\setlength{\parskip}{0.5\baselineskip}
\setlength{\parindent}{0pt}

\title{Type-Safe FIDE / SQL Server Interfaces}
\author{Final FIDE Review Meeting, Hamburg \\ \ \\
Florian Matthes, Andreas Rudloff, Joachim W.~Schmidt, Kazimierz Subieta \\
Hamburg University}
\date{September 1992}

\pagestyle{myheadings}
\markright{Type-Safe FIDE / SQL Server Interfaces, Demonstration, September 1992}
\begin{document}
\maketitle

\raggedright
\section*{Objectives of the Demo}

The purpose of this demonstration is to show how existing commercial
relational database management systems can be deeply integrated into
type-safe FIDE language environments. This integration is of high
relevance for the commercial exploitation of FIDE technology since it
provides the basis for a smooth migration path from todays system
solutions to new FIDE services.  On the other hand, the integration
process itself poses challenging demands on FIDE languages and their
supporting system architectures.

The demonstration covers two conceptually complementary approaches to
server integration:

\begin{description}
\item[DBPL SQL Gateway:]
A built-in, transparent approach to server integration

\item[Tycoon Library:]
An add-on, extensible approach to server integration
\end{description}

The functionality of the DBPL gateway is demonstrated using a DBPL
application that maintains a large on-line module and identifier
database which is identical to the stand-alone DBPL application
demonstrated at the previous FIDE review.

The underlying SQL database is also used for the demonstration of the
Tycoon Library.

\newpage
\section*{The DBPL SQL Gateway: An Overview}

During the last year, the DBPL system available on Sun/SunOS and VAX/VMS
platforms was extended by a set-oriented gateway to external relational
databases (Ingres 6.3). It provides a fully transparent access to
external (pre-existing or dynamically created) SQL databases in addition
to type-complete DBPL-specific complex object databases. 

The gateway preserves the linguistic qualities of DBPL like
\begin{itemize}
  \item strong typing
  \item static binding
  \item user-defined data types
  \item application modularization
  \item generalized iteration abstractions
  \item fixed-point queries 
  \item transactional procedures
\end{itemize}

\noindent while exploiting the services of todays set-oriented storage servers
\begin{itemize}
  \item extensive access optimization
  \item access protection
  \item concurrency control
  \item crash recovery
  \item ad-hoc query interfaces, form interfaces, \ldots
\end{itemize}

\noindent The gateway is responsible for
\begin{itemize}
  \item data type conversions
  \item query transformations (e.g. universal quantification, parameterization)
  \item host variable and cursor handling (e.g. in recursive procedures)
  \item evaluation of "mixed" queries (involving DBPL and SQL objects)
  \item multi-server transaction management
    (integration of DBPL and SQL concurrency control and recovery)
\end{itemize}

\newpage
\section*{A Built-In Approach to Server Integration}

\begin{center}\leavevmode
\epsfxsize=0.6\textwidth
\epsfbox{DBPLOverview.ps}
\end{center}

\begin{itemize}
\item Seamless integration of \e{external} and \e{internal} services
\item Localized DBPL runtime system extensions
\item No need for DBPL language extensions
\item Type orthogonality restrictions on external databases
\begin{itemize}
\item Persistence only for relation variables
\item No support for non-flat relations
\item Restrictions on the maximum tuple size
\end{itemize}
\end{itemize}

\newpage
\section*{Implementation Overview}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsfbox{dbpl-components.ps}
\label{Abb:DBPLArch}
\end{center}

Extensions to the predicate management system (CPMS):
\begin{itemize}
\item 1600 lines dynamic SQL/C code
\item 5400 lines Modula-2 code
\item 1000 lines revised Modula-2 code
\item $\Rightarrow$ 10\% of the total DBPL system code
\item 12 man-months
\item SQL Sever: Ingres 6.3 (Oracle 6.0)
\item Available on Sun-3, Sun-4, VAX (and IBM RISC) platforms
\end{itemize}

\newpage
\section*{Example Application}

\begin{description}
\item[Task] Maintenance of an online module cross reference database that
stores information about
  \begin{itemize}
  \item compiled DBPL module definitions, module implementations and
        application programs;
  \item identifiers declared in module definitions (transactions, procedures,
        types, database variables, etc.);
  \item module import dependencies;
  \item identifier dependencies (e.g., variables depend on their
        types, procedures depend on their parameter types).
  \end{itemize}

\item[Test Data] 5 tables
  \begin{itemize}
    \item 223 modules
    \item 3509 identifiers
    \item 5135 direct declaration dependencies
    \item 43954 identifier occurences
  \end{itemize}

\item[Approach] A modular DBPL application program consisting of
  \begin{itemize}
   \item a global SQL database: module \k{DBXRef} importing \k{DBXRefTypes}
   \item a procedural interface to the DBPL compiler: \k{DBXRefO}
   \item a menu-driven text window interface for browsing: \k{DBXRefMenu}
   \item two main programs: \k{dbplxref}, \k{dbplxrefclean}
  \end{itemize}
\end{description}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{DBXRef-Architecture.ps}
\end{center}

\newpage
\section*{DBPL / SQL Demo Menu}

\begin{center}\leavevmode
\epsfxsize=0.6\textwidth
\epsffile{title.ps}
\end{center}

\begin{itemize}
\item Integration of DBPL and Ingres tools (Ingres 4GL)
\item Interactive users
\item DBPL applications
\item Standard ESQL applications
\end{itemize}
\newpage
\section*{Dynamic Binding of SQL Databases}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{dbplbind.ps}
\end{center}

\begin{itemize}
\item Strong type compatibility check (e.g. null values) between
\begin{itemize}
\item DBPL database schema (\k{DATABASE DEFINITION MODULE})
\item Ingres database schema
\end{itemize}
\item Data type conversion (e.g. enumeration types, subrange types)
\item Detailed data format control (e.g. string sizes)
\item Helpful error messages
\end{itemize}

\newpage
\section*{Accessing SQL Databases from Compiled DBPL Programs}

\begin{itemize}
\item Display all module identifiers in the database
\item Select module CPMS\\ (an implementation module of the DBPL runtime
system, see page \pageref{Abb:DBPLArch})
\end{itemize}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{select-cpms-dependson.ps}
\end{center}

\begin{itemize}
\item \e{Canned} parameterized queries
\item Expressions involving external SQL and temporary DBPL relations
\item Stack of intermediate results
\item Generic DBPL form interface
\end{itemize}

\newpage
\section*{Navigation through the Cross Reference Database}

\begin{itemize}
\item List the  modules imported by module \k{CPMS}
\item List all declarations exported by module \k{SQLEval}
\item Display the source code of a declaration
\end{itemize}

\begin{center}\leavevmode
\epsfxsize=0.75\textwidth
\epsffile{sqlevaldeclarations.ps}
\end{center}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{card-in-emacs.ps}
\end{center}

\newpage
\section*{Implementation Aspects}
\begin{itemize}
\item Associative DBPL queries transparently translated into SQL queries:
\begin{verbatim}
    DepRel := DepRelT{{i.Name, id.Name, id.Kind, i.ID, id.ID} OF
                EACH i IN IdentRel,
                  EACH id IN IdentRel,
                    EACH dep IN DependsOnRel: 
                        (dep.IdentID = loc.Id) AND
                        (i.ID = dep.IdentID) AND
                        (id.ID = dep.DependsOnID)};
\end{verbatim}
\item Query execution plan based on case analysis:

Pure DBPL, pure Ingres, top DBPL, top Ingres, mixed join, badly mixed

\item Global optimizer, local DBPL query optimizer, local SQL query
optimizer

\item Selectors, constructors, recursive queries implemented on top of
set expressions

$\Rightarrow$ Recursive SQL queries
\end{itemize}

\begin{verbatim}
    CONSTRUCTOR NextModules WITH (root:ID): IdRelT;
    BEGIN
      root,
      d.IdentID OF EACH d IN DependsOnRel:
        SOME s IN IdRelT{NextModules(root)} (d.DependsOnID = s)
    END NextModule;
\end{verbatim}

For a given parameter (e.g. \k{30}), the application of the constructor
defines the set of all keys of modules that transitively depend on the
module with the key \k{30}.
\begin{verbatim}
  modules:= IdRelT{NextModule(30)};
\end{verbatim}
\newpage
\section*{Query Translation and Concurrency Control}

The following stand-alone DBPL program is executed against the
cross-reference database. All data exchanged between the DBPL runtime
system and the SQL server is displayed on the screen.


\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{dbxrefmy.ps}
\end{center}

\begin{itemize}
\item Translation of universal quantifiers
\item Non-set expressions
\item Update statements
\item Concurrency control, recovery
\end{itemize}

\newpage
\section*{An Add-On Approach to Server Integration}

\e{Tycoon} (TYped Communicating Objects in Open eNvironments):

A uniform linguistic and architectural framework for the integration of
\e{generic} database services:
\begin{itemize}
\item Bulk data storage
\item Data manipulation
\item Graphical display
\item Network communication
\item \ldots
\end{itemize}

\begin{itemize}
\item Provide extensive library support for data-intensive applications
\item Exploit existing commercial servers
\item High-level application and system programming framework (TL)
\item Scalable system architecture
\end{itemize}

\begin{center}\leavevmode
\epsfxsize=0.75\textwidth
\epsffile{Tycoon-Layers-Engl.ps}
\end{center}


\section*{An Exercise in Interoperability}

Pre-existing, independently developed languages and abstractions
\begin{itemize}
\item SQL syntax
\item Iterators in the Tycoon libraries
\item SQL server (cursors, statements, buffer descriptors, \ldots)
\item Tycoon bulk data types
\item NeWS window server
\end{itemize}

\begin{center}\leavevmode
\epsfxsize=0.6\textwidth
\epsffile{task.ps}
\end{center}

Subasks
\begin{itemize}
\item Scanning, parsing, error reporting
\item Expression analysis: scoping, semantic checking
\item Expression translation
\item Data browsing
\end{itemize}

General DBPL issues
\begin{itemize}
\item Syntactic support
\item Genericity
\item Reusability of system components
\item Ease of implementation
\end{itemize}

\newpage
\section*{Demonstration Environment}

\begin{itemize}
\item Napier persistent object store (garbage collection, stability)
\item P-Quest language processors
\item Generic Tycoon libraries ($>$ 200 modules)
\item Ingres 6.3
\item NeWS/X11 window server
\end{itemize}

\begin{center}\leavevmode
\epsfxsize=0.5\textwidth
\epsffile{Tycoon-Architecture.ps}
\end{center}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{Tycoon-Screen.ps}
\end{center}

\section*{Special-Purpose vs.~Generic Solutions}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{Tycoon-Abstractions.ps}
\end{center}

\begin{itemize}
\item Smooth transition from system to application programming
\item Extensibility at various levels of abstraction
\item Syntactic extensibility to support ``language specializations''
\begin{itemize}
\item Application-domain-specific abstractions (e.g. grammars, forms)
\item Application-specific abstractions (e.g. query operators, database objects)
\end{itemize}
\item High demands on language genericity and binding flexibility
\end{itemize}

\section*{The Modular Implementation}

\begin{center}\leavevmode
\epsfxsize=\textwidth
\epsffile{tasks2.ps}
\end{center}

FIDE Technology
\begin{itemize}
\item Reflection
\item Language processing in persistent environments
\item Bulk type generalisation
\item Type-safe external interfaces
\end{itemize}



\end{document}
