% File: fidedemo.tex
% Date: 20.9.1991
% Author: FM
% Subject: FIDE DBPL demo

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

\title{FIDE Sun-DBPL System Demonstration}
\author{2nd Annual FIDE Review Meeting, Glasgow \\ \ \\
J.W.~Schmidt, M.~Lang, F.~Matthes, A.~Rudloff \\
Hamburg University}
\date{September 1991}

\newcommand{\k}[1]{{\tt #1}}
\newcommand{\figwidth}{14cm}

\pagestyle{myheadings}
\markright{FIDE Sun-DBPL System Demonstration, September 1991}
\begin{document}
\maketitle

\section*{Objectives of the Demo}
\begin{enumerate}
\item Current database systems provide a wide class of services that
need to be absorbed by the FIDE technology:
      \begin{itemize}
      \item optimized queries
      \item declarative extensions, data deduction, views
      \item efficient persistence \\ \ \\
      \item transactions: concurrency, recovery
      \item interoperability in open systems
      \end{itemize}

\item The demonstration of the DBPL system and language covers that range of
services and shows an adequate and homogeneous linguistic interface
that also supports software engineering demands:

    \begin{itemize}
    \item type orthogonality
    \item query abstraction
    \item orthogonal persistence and transactions \\ \ \\

    \item database modules, implementation modules, program modules
    \item external interfaces, e.g. screen management systems and 
          process management
    \end{itemize}

\item There are novel classes of demands for database programming (e.g. for
generic database applications).
\end{enumerate}

\newpage
\section*{Structure of the Demo}
\begin{enumerate}
\item DBPL System Overview: System Architecture and Size
\item DBXRef: A Database for Module, Name and Type Dependency Management
\item Demo Script
     \begin{enumerate}
     \item Display all existing modules
     \item Display database definition module
     \item Display corresponding DBPL source code
     \item Display type declarations
     \item Display transitive import relationship
     \item Compile a new DBPL program in multi-user mode
     \item Display updated database 
     \item Link and execute DBPL application program
     \end{enumerate}
\end{enumerate}


\newpage
\section{DBPL System Overview}

\begin{center} \leavevmode
\epsfxsize=\figwidth
\epsffile{DBPL-Architecture.ps}
\ \\ \ \\ \centerline{DBPL System Architecture}
\end{center}


%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{DBPL-Sizes.ps}
\ \\ \ \\ \centerline{DBPL System Component Sizes}
\end{center}
%\end{figure}

\newpage
\section{DBXRef: A Database for Module, Name and Type Dependency
Management}

\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[Approach] A modular DBPL application program consisting of
  \begin{itemize}
   \item a global DBPL database: modules \k{DBXRef}, \k{DBXRefType}
   \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}

\item[Test Data] Modules and identifiers of the DBXRef application itself:
  \begin{itemize}
    \item 12 modules
    \item 161 identifiers
    \item 148 direct declaration dependencies
    \item 631 identifier occurences
  \end{itemize}
\end{description}

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{DBXRef-Architecture.ps}
\ \\ \ \\ \centerline{Modules of the DBPL Demo Application}
\label{DBPL-Arch}
\end{center}
%\end{figure}

\newpage
\section{DBPL Demo Script}

\subsection{Display modules}

The first query is to display all identifiers of Kind \k{MODULE}.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Dump-All-Modules.ps}
\ \\ \centerline{Listing of all modules stored in the cross reference database}
\end{center}
%\end{figure}

\ \\ \ \\
Introduction into example
\begin{itemize}
\item Application
\item Database
\end{itemize}

\newpage
\subsection{Display database definition module}

By moving the cursor to the module \k{DBXRef} and selecting it, details
about the module are displayed:

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Dump-DBXRef-Form.ps}
\ \\ \centerline{Information about the module DBXRef}
\end{center}
%\end{figure}

\ \\ \ \\
Introduction into example (cont'd)
\begin{itemize}
\item Application Data
\item Form Interface
\end{itemize}

\newpage
By selecting the menu item \k{Declarations}, all names exported by the module
\k{DBXRef} are displayed.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Dump-DBXRef-Decl.ps}
\ \\ \centerline{Listing of all identifiers declared in module DBXRef}
\end{center}
%\end{figure}

\ \\ \ \\
\begin{itemize}
\item Access Abstraction
\end{itemize}


\newpage
\subsection{Display DBPL source code}

By moving the cursor over an individual identifier (\k{IdentRel}),
details about the identifer are displayed. Selecting the menu item
\k{Show File} immediately starts a subprocess from within the DBPL application
to display the declaration point of an identifier using a standard
editor. The cursor is positioned into the line that contains the
declaration of the identifier.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Editor-Call.ps}
\ \\ \centerline{Calling the editor}
\end{center}
%\end{figure}
%\begin{figure}[htbf]
\begin{center}\leavevmode
\begin{verbatim}
DATABASE DEFINITION MODULE DBXRef;
IMPORT
  DBXRefType;
VAR                                  (* persistent database variables:   *)
  IdentRel        : DBXRefType.IdentRelT;
  ModuleRel       : DBXRefType.ModuleRelT;
  DependsOnRel    : DBXRefType.DependsOnRelT;
  DefModOccurRel, 
  ImpModOccurRel  : DBXRefType.OccurRelT;
  IdentCt         : DBXRefType.ID;   (* highest ID key issued up to now. *)

  TRANSACTION InitDB;
END DBXRef.
\end{verbatim}
\ \\ \centerline{The source code of the DBPL database module \k{DBXRef}}
\end{center}
%\end{figure}

\begin{itemize}
\item Orthogonal Persistence
\item Software Modularity
\end{itemize}

\newpage
\subsection{Display type declarations}

A variable declaration depends on its corresponding type declaration.
Again, this dependent identifier (\k{IdentRelT} declared in module
\k{DBXRefType}) can be inspected by navigation with the
browser (menu item \k{Depends On}) followed by an editor call.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\begin{verbatim}
DEFINITION MODULE DBXRefType;
CONST 
  Maxstring     = 20;
  LongMaxstring = 256;
  UnknownID     = 0;  (* reserved ID value *)
  NotFoundID    = 1;  (* reserved ID value *)
  
TYPE 
  ID            = CARDINAL;
  TypeClass     = (basesc, setsc, pointersc, relationsc,
                   procsc, enumsc, subrangesc, arraysc, recordsc, predicatesc,
                   dummyc);
  IdKind        = (modulesk, procsk, typesk, constsk, varsk, fieldsk, 
                   predicatesk, 
                   dummyk);   (* dummy kind for interactive queries *)
  DeclKind      = (inmodule, inrecord, inenum);
  ShortString   = ARRAY[0..Maxstring-1] OF CHAR;
  Identifier    = RECORD
        ID         : ID;          (* system-generated unique key        *)
        Name       : ShortString; (* identifier declared in a program   *)
        Anonymus   : BOOLEAN;     (* is this an anonymous identifier?   *)
        Kind       : IdKind;      (* kind of entity denoted by ID       *)
        Type       : TypeClass;   (* type if kind = typesk else dummyc  *)
        DeclLine   : CARDINAL;    (* line number where ID is declared   *)
        DeclModule : ID;          (* compilation unit where ID is decl. *)
        DeclKind   : DeclKind;    (* the kind of scope for ID           *)
        DeclName   : ID;          (* the identifier for the scope       *)
      END;
  IdentRelT     = RELATION ID OF Identifier;
     (* One entry per identifier [module, variable, type, constant, type, 
        selector ... record field] declared in a definition module. *)
\end{verbatim}
\ \\ \centerline{The declaration of the type \k{IdentRelT} in module \k{DBXRefType}}
\end{center}
%\end{figure}

\ \\ \ \\
\begin{itemize}
\item Expressive Database Typing
\item Modularization and Scoping
\end{itemize}

\newpage
The previous query to display all dependent identifiers of a given identifier
(\k{loc.Id}) with their identifier requires a three-way join between
the database relations \k{IdentRel} and \k{DependsOnRel}. The DBPL query
optimizer transforms this query into an execution plan that requires
only a single scan over \k{DependsOnRel}.

\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}

\ \\ \ \\
\begin{itemize}
\item Access Abstraction
\item Query Optimization
\end{itemize}


\newpage
\subsection{Display transitive import relationship}

The import of a module interface A into a module B introduces a direct
dependency of B on A. For example, a change of the database module
\k{DBXRef.def} requires a recompilation of \k{DBXRefO.mod} that operates on the
database variables. In addition to the display of direct dependencies,
the demo application also provides support to display the induced
transitive dependencies.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Transitive-Dependencies1.ps}
\ \\ \centerline{Modules that transitively depend on the interface of \k{DBXRef}}
\end{center}
%\end{figure}

The computation of this transitive relationship is achieved declaratively
by the following recursive constructor that has (stratified) least
fixed-point semantics:

\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}
\begin{itemize}
\item Data Deduction
\item Access Optimization
\item Parameterization
\end{itemize}

\newpage
\subsection{Compile a DBPL program in multi-user mode}

To demonstrate that the module dependency database is updated
automatically by the DBPL compiler, the DBPL compiler is started in a
separate session (possibly on a different network node):
\begin{verbatim}
    dbplc -list -trace MyModule.mod 
\end{verbatim}
The write access of the compiler to the database as well as the read
access of the interactive browser are both part of transaction
executions. The compilation transaction is therefore automatically
suspended by the DBPL scheduler until the interactive transaiiton is
commited. The communication between DBPL applications is performed by
the module \k{LMS} (see Fig.~\ref{DBPL-Arch}).

%\begin{figure}
\begin{center}
\begin{verbatim}
MODULE MyModule;

FROM DBXRef IMPORT IdentRel, ModuleRel;
FROM DBXRefType IMPORT Module, ModuleKind, IdKind, IdentRelT;
IMPORT Assist;

TRANSACTION T;
  VAR
    age: [0..20];
    result: IdentRelT;
BEGIN
  result:= IdentRelT{EACH id IN IdentRel: id.Kind = procsk};
  INCL(ModuleRel, Module{500, "MyNewModule.def", defM});
  Assist.DisplayRelation(result, 1, 1, 70, 20, "Result");
  age:= 20;
  INC(age);  (* cause a range-check violation at runtime *)
END T;

BEGIN
  T;
END MyModule.
\end{verbatim}
\end{center}
\ \\ \centerline{Contents of the file \k{MyModule.mod}}
%\end{figure}

\ \\ \ \\
\begin{itemize}
\item Orthogonal Transactions
\item Concurrency Control
\end{itemize}

\newpage
\subsection{Display updated database}

Since \k{MyModule} imports \k{DBXRef}, the set of transitive
dependencies of \k{DBXRef} is correctly augmented by \k{MyModule.mod}.

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Transitive-Dependencies2.ps}
\ \\ \centerline{Updated list of modules that transitively depend on the interface of
\k{DBXRef}}
\end{center}
%\end{figure}

\newpage
\subsection{Link and execute a DBPL program}

To execute the DBPL application \k{MyModule} that was already
successfully compiled in the previous step, it first has to be linked
with the imported (database) modules and the database system support
code:
\begin{verbatim}
   dbplc -e MyModule -o MyModule -L/usr/5lib -lcurses -ltermcap
\end{verbatim}
The generated stand-alone executable file can be started like any ordinary
Unix program:
\begin{verbatim}
   MyModule
\end{verbatim}
and displays the result of the query, namely all procedure identifiers
declared in all modules. The subrange constraint violation in the above
transaction leads to a transaction abort. The DBPL database system
ensures that all updates to the database are undone:

%\begin{figure}[htbf]
\begin{center}\leavevmode
\epsfxsize=\figwidth
\epsffile{Crash-Log.ps}
\ \\ \centerline{Exception handling and error recovery in DBPL}
\end{center}
%\end{figure}

\ \\ \ \\
\begin{itemize}
\item Exceptions, Subrange Tests
\item Recovery
\end{itemize}

\end{document}

