RAQUEL the Language
RAQUEL stands for Relational Algebra, Query, Update and Executive Language.
When Ted Codd invented the relational database, his aim was to provide the user with a simple but powerful database facility. This evolved into SQL database systems during the 1970s. Alas, their descendents are now widely regarded as cumbersome and complex systems that do not implement the full relational model and even contradict it in places. See for example some problems with SQL.
RAQUEL is a database programming language that aims to fulfil Codd’s original vision, and indeed to go beyond what could have been envisaged in Codd’s day. To achieve this, RAQUEL provides the complete relational model of data together with full data independence. Furthermore RAQUEL as a language organises these concepts so as to maximise programmer productivity. In summary :
- RAQUEL’s logical model of data is the relational model, and it includes the latest refinements and extensions as specified by The Third Manifesto. Relational algebra (as opposed to relational calculus) is used to manipulate relations. RAQUEL also uses a type system that allows any type of data to be held in relations.
- RAQUEL’s model of data independence is orthogonal to the relational model. It uses an extended ANSI/SPARC 3-layer architecture to provide full Logical and Physical Data Independence. As a result, relational data may be held in a variety of configurations, in multiple locations, and with multiple copies, in order to achieve the desired physical performance with appropriate resilience and recovery.
- RAQUEL as a language is designed and organised to maximise the ratio of function to conceptual complexity, as defined by Fred Brooks in his Essays on Software Engineering. This maximises ease of use and learning while endowing the language with the maximum of functionality.
Examples of RAQUEL Code
Car Restrict[ Engine > 2.4 ] Join[ OffID ] Office Project [ Type, Address ]
Let the relational variables Car (about cars) and Office (about offices), together with the attributes they contain, be part of a database of a car hire company that has a number of rental offices. The expression then evaluates to the answer of the query “What are the types of car with engines greater than 2.4 litres, and at what offices are they located ?”. The Car relation is Restricted to those tuples describing cars with an engine size greater than 2.4 ; that result is Joined to those tuples in Office about offices that have the same office ID value ; from the join result the car type and office address are Projected out.
s <--Retrieve
Office Union Temp
<--Insert
{ { OffID <-- ‘DR’; Address <-- ‘Durham’ }
{ OffID <-- ‘NE’; Address <-- ‘Newcastle’ } }
This Inserts a relational value of 2 tuples, each consisting of the 2 attributes called ‘OffID’ and ‘Address’, into a relation called Temp, which is then Unioned with the Office relation, and the result of the union Retrieved as the answer to a query. ‘s’ represents the location to which the query answer is sent; any relevant name could be used for this purpose. Note that Temp will still hold the 2 tuples after the retrieval has been carried out, presumably ready for a subsequent statement that uses this value of Temp.
If the relational algebra expression which forms the first example were to be put as the right hand side of a <--Retrieve, then the value of that expression would be retrieved. In fact if a statement consists solely of a relational algebra expression, then by default RAQUEL puts a <--Retrieve to a default output to the left of the expression; thus the first example forms a query anyway.
For more examples of RAQUEL, see the example RAQUEL statements.
To explore the RAQUEL notation further, you can execute these statements, and others of your own invention, on a prototype RAQUEL DBMS. The DBMS comes with a GUI frontend with which to enter statements. The example statements are intended for a Demonstration Database. The prototype DBMS, GUI frontend, and Demonstration DB are all downloadable from SourceForge. See the Home Page / Demonstration Prototype menu option for further details.
Yet more examples of RAQUEL arise from an SQL course in which RAQUEL is used to teach the relational principles underpinning SQL, and to highlight the relational deficiences of SQL. All the course materials are accessible from the "Using RAQUEL to Teach SQL" menu option.
Features of RAQUEL
- Novel features :
- Variables are considered to have 3 parts : their data value, their integrity constraints (which include their data type), and a binding to their physical storage. Consequently assignments are generalised to handle all 3 cases, with one subcategory of assignments assigning data values, another assigning integrity constraints, and a third assigning bindings.
- When creating a relational variable, it is not necessary to bundle all the relevant factors into one CREATE statement. Each factor - attribute(s), candidate key(s), referential integrity, etc - is specified separately with its own assignment to the variable, as and when required. This provides much greater flexibility in implementing database designs.
- Consequently the new forms of assignment replace traditional variable declarations, which are dispensed with.
- An assignment is treated as a form of operator, so that a RAQUEL statement is an assignment expression which can use traditional algebraic expressions as operands. This provides flexibility of expression and enables multiple actions to be executed in one statement.
- Logical and physical data independence may be applied to individual scalar values as well as relations. In other words, scalars may have alternative logical appearances (e.g. points may be expressed with Cartesian Coordinates or Polar Coordinates) and alternative physical storage methods (e.g a picture may be stored in a TIFF or a JPEG file).
- RAQUEL has both a Natural Join and a Generalised Join operator. Both are conceptually extendable in the same way so that they can handle not only traditional inner joins but also semi joins (left and right) and outer joins (left, right and full). This full set of 12 join operations also allows cartesian products to be executed as a natural special case.
- Other significant features :
- The syntax of RAQUEL is defined separately from its semantics. While there can only be one semantics, the separation allows multiple syntaxes to be defined. Currently only the linear text syntax illustrated above exists. However a graphical syntax is under consideration. Syntaxes for non-Western style languages, ‘sound syntaxes’ for visually impaired people, and so forth, are also facilitated.
- Semantically the procedures in RAQUEL fall into 2 disjoint sets. Firstly there are algebra operators, which are mathematical functions with no side effects, and secondly there are assignments, which carry out actions affecting the database. The first example above illustrates the use of relational operators to form a relational expression. The second example illustrates the use of relational assignments to carry out 2 actions involving relations in the database.
- RAQUEL has no need of NULLs (unlike SQL), and consequently uses traditional 2-valued logic instead with truth values 'true' and 'false'. This makes the writing of truth valued expressions much less error prone than in SQL.
- The semantics of RAQUEL constitute a formal logical model,
in the same mathematical sense that differential calculus constitutes a formal logical model.
The logical model encompasses the set of relational variables forming a database and their logical manipulation,
excluding all reference to physical implementation.
For completeness the logical model has an adjunct that enables the Database Administrator (say) to define the physical storage of database data and to specify controls to manage user access to the database.
Further details
The RAQUEL database programing language started as a teaching language at Northumbria University in 1991. It has evolved since then as a result of significant research and development work. It has also been used on a major scale for teaching, which has provided important feedback to support the enhancement and improvement of the language. See the "Project History" menu option for details.
See RAQUEL in Summary for an overview of RAQUEL, particularly as regards the current prototype RAQUEL DBMS. See the "Description of RAQUEL" menu option for more details of RAQUEL as a database programming language.