=Paper=
{{Paper
|id=Vol-1/paper-9
|storemode=property
|title=Generating queries from complex type definitions
|pdfUrl=https://ceur-ws.org/Vol-1/jeusfeld-long.pdf
|volume=Vol-1
|authors=M.A. Jeusfeld
}}
==Generating queries from complex type definitions==
https://ceur-ws.org/Vol-1/jeusfeld-long.pdf
Generating queries from complex type de nitions
Manfred A. Jeusfeld
Informatik V, RWTH Aachen, D-52056 Aachen
jeusfeld@informatik.rwth-aachen.de
Abstract case of relational databases, only at relations
can be expressed. In the case of object-oriented
Many information systems are imple- databases, the type system depends on the spe-
mented as application programs connected ci c data model of the database system.
to a database system. A characteristic
problem of such systems is the famous Handcoded clustering by lter procedures
impedance mismatch, i.e., the conceptual within the application program is error-prone
distance between the programming and the and gives away the chance of reasoning on
database languages. The traditional solu- the relationship between the information in the
tion is to implement an interface that trans- database and in the application program.
forms one representation into the other. Section 2 introduces API modules as the interface
Commercial database systems o er prepro- between the database and the application program.
cessors that allow to embed the database Base types are imported from the database. Appli-
language (e.g., SQL) into the programming cation speci c types are de ned by using tuple, set,
language (e.g., C). Such an approach frees and pointer constructors. The latter allows to rep-
the application programmer from the task resent recursive concepts of the database schema.
to specify details of the communication. Section 3 presents the mapping of the API mod-
However, the impedance mismatch is not ules to a logic program delivering complex terms.
solved but aggravated. The set-oriented These terms are read by a parser that itself is gen-
database language is intermixed with the erated from the API modules.
element-oriented programming language, a Section 4 relates the types in an API module to
notorious cause for programming errors. statements of a concept language. Thereby, types of
Moreover, there is no support in map- two di erent API modules can be checked for sub-
ping the restricted data representation of sumption and consistency.
databases into the more complex type sys-
tem of programming language. This pa- 2 Interface Modules
per proposes an intermediate language, the
API modules, for specifying the relation- Interfaces between imperative-style programming
ship between the representations in the languages should both re ect the major type con-
database and in the application program. structors and the facilities of the database query
The query for retrieving the information language. The most common type constructors are
and the data types for storing it can be tuple and set. Some languages also support lists.
generated from the API module. The mod- Pseudo-recursive type de nitions are possible when
ules are simple enough to allow reasoning allowing pointer types, e.g. in C and Modula-2.
on queries generated from them. Common base types are Integer and String. The
denotational semantics of a type expression is a po-
tentially in nite set of values, for example [Inte-
1 Introduction ger,String] denotes the cartesian product of the se-
The purpose of a database system is to maintain a mantics of the component types.
large amount of information for a variety of appli-
cation programs. The application-speci c clustering 2.1 Example
is either described as a database view de nition or Assume a database provides information about a
performed by lters inside the application program. company. An application programmer has the task
Both approaches have their disadvantages: to process the information about the projects of em-
View de nition languages are restricted to the
ployees who work for a given department. The API
type system of the database system. In the module could look as in Figure 1.
The FROM clause imports concepts from the
This work was partly supported by the Commission database schema. They are used like ( nite) base
of the European Union under ESPRIT BRA 6810 (Com- types. Their extension is represented in the current
pulog 2). database state. The TYPE clauses declare complex
API-MODULE Emps; hasType(T,T(_X,_Y1,...,_YK) :-
FROM CompanyDb IMPORT Employee, Project,
Department, String; In(_X,C),
TYPE