Xref: utzoo comp.databases:8552 comp.object:2435 comp.lang.c++:11298 Path: utzoo!utgpu!watserv1!watmath!att!pacbell.com!ucsd!sdd.hp.com!cs.utexas.edu!convex!texsun!smunews!ti-csl!tilde.csc.ti.com!usenet From: blakeley@osage.csc.ti.com (Jose' A. Blakeley) Newsgroups: comp.databases,comp.object,comp.lang.c++ Subject: Use of queries in a programming language. Message-ID: <1991Jan25.044634.23727@csc.ti.com> Date: 25 Jan 91 04:46:34 GMT Sender: usenet@csc.ti.com (USENET News System) Organization: TI Computer Science Center, Dallas Lines: 84 The purpose of this posting is to probe the programming languages and database communities about the expected need for an associative query capability in a programming environment. As a background note, I am part of a research team at Texas Instruments responsible for building an object-oriented database management system. Due to a lack of a formal, universally accepted object data model, we adopted the type system of an object-oriented programming language X, where X=C++,CLOS,... as a basic data model for the system. Our approach is similar to other efforts currently underway at several OODB companies. We denote the basic API of the programming language X augmented with database amenities like persistence, transaction management (concurrency control and recovery), and type management (data dictionary) as Persistent[X]. To complement Persistent[X] we have built a prototype of an associative object query capability denoted OQL[X]. One of the primary design goals of OQL[X] is to provide a smooth integration of query statements with the normal programming language statements of X. OQL[X] can be seen as a hybrid of SQL and statements from X. The structure of an OQL[X] query statement is: = SELECT FROM IN WHERE ; where is a collection-valued variable in a program; describes the type of the objects in the response collection; is a variable declared using syntax of a variable declaration in X which ranges over the objects of ; is a collection-valued program variable or function, or object stored in the database; and is a Boolean expression describing the condition to be satisfied by the objects in the response collection. The following example illustrates the use of an OQL[C++] statement within a C++ program. People familiar with embeddings of SQL in programs may wish to compare this code with the amount of code required to formulate a similar query in a relational system using embedded SQL. Note that the use of set-valued variables eliminates the need for cursors. class Person{public: char* name(); ...}; class Medical_Record{public: Date date(); char* diagnosis();...}; class Patient: Public Person{public: Set medical_records(); Physician *physician();...}; ... main() { Set mypatients, result; Patient p1, p2; ... // code that creates instances of // of patients not shown mypatients.Insert_Member( p1 ); // insert a member to the set ... Query{ Date *d = new Date( 12, 11, 90 ); result = SELECT p FROM Patient *p IN Patient_Set WHERE p->physician()->name()->last() == ``Smith'' && EXISTS ( SELECT r FROM Medical_Record *r IN p->medical_records() WHERE r->date() < d && r->diagnosis() == ``flu'' ) ; } }; I would appreciate any information, feedback, or comments from the programming languages and database communities about the degree of interest, desirability, and usability of such an associative query capability to complement a programming language X. Please send your comments to blakeley@csc.ti.com. If there is enough interest and responses to this inquiry I promise to summarize them and post them in this news group. There is also a technical report that provides a full description of OQL[C++]. I will be happy to send copies to interested people. Thank you in advance for your help. // Jose' A. Blakeley // Information Technologies Laboratory // Texas Instruments // P.O. Box 655474, MS 238 // Dallas, Texas 75265 (214) 995-0362.