RELATIONAL ALGEBRAS, LOGIC, AND FUNCTIONALPROGRAMMING Cirrus Computers Ltd.,29/30 Patrick A.V.

Hall High Street, Fareham, PO16 7AD, England.

ABSTRACT Relational algebras as developed by Codd and his followers are extended by noting an equivalence with functional languages. This leads to higher order relatione, recursive definition8 of relations, and the use of higher order relations as recursive data structures. This equivalence on of databases the one hand enables the technology to be used within the context of applicative languages, and on the other hand removes the adhoc mechanisms used for higher order operations in relational databases. This leads from 4th to 5th generation data management, exploiting the mathematical foundations of functional languages and logic programming, and the technology of relational database. 1.0 INTRODUCTION

non-procedural or semi-procedural languages [e.g. The facilities are often GRAD 83, MCCR 801. loosely founded on the relational theories of Codd [CODD 721 but add various additional facilities in ad hoc manner. In this paper I start with relational databases, and interpret the relational algebra functionally, to extend thie to embrace all the power and theoretical neatness of functional languages. In doing this my intentions are twofold. to provide a theoretical basi8 for the 4th generation data processing languages, to enable them to move into the 5th generation. logic, and functional, integrate to relations1 languages so that they can share technology. This exploration is by no meens complete, for a the time dimension and updates, critical aspect, However this paper must has not been addressed. be viewed as a necessary pre-requisite for that later study. In section 2, the historical and study is described, work explained. background relationships to this to other

Logic programming and functional programming have become very fashionable through interest recently in "5th generationI computing. Logic and functional programming have, of course, been around a long time. So has the application of computers to commerce, and the use of databases for that application. Logic prcgmnming has seen the challenge and responded to it [GN 781. Functional programming appears not to have, except in the use of functional ideas in some query languages IBF 79, SHIP.811. Yet it is databases that form the foundation of a very large bulk of computing applications, from COFIOL systems to those usillg moat the sophisticated data management software. In this area we are seeing the emergence of a large number of commercial systems, often styled "4th Generation", based on data dictlonaries and providing various facilities t-ugh

In section 3, the relational algebra is developed This correspondence as an applicative language. with applicative languages adds capabilities to with recursive definitions, higher the algebra, order relations, and recursive data Structures, presented in Section 4 and 5. An example is given in Section 6.
2.0 BACKGROUND

Perm~smonto copy wlthout fee all or part of tbls matenal IS granted provaicd that the copies arc not made or dlstnbutcd for drrcct commercud advantage, the ACM copyngbt notice and the tltk of the pubhcatron and I@ data appear, and no& IS @ven that copymg IS by pcrmlsslon of the Assoclauon for Computmg Machmery To copy otbenvlsc, or to rcpubbsb, rcqturcs a fee and/or spccdic pcrmlsslon 0 1984 ACM 0-89791-128-8/84/006/0326 $00 75

During the development of the research relational database system PRTV [TODD 761 at IBM Peterlee, algebra was used as the data the relational In its original form [coDD manipulation language. 701, relations had been defined as subsets of Cartesian products on a number of domains. In order to achieve a position independent notation for relations, the 'columns were distinguished by the domain name, or where several domains were the sane, by a 'role name'. However there were some technical problems with the name inheritance in operations of the relatlonal algebra. the 1join' The key relational operation is the 'equi-join', are combined in a Cartesian where two relations

326

recently. now been explored in depth [e. and definitional equations. braces v(** and 11)'1are metasymbols and have been they are included in quotation marks where required as terminal symbols. and B a column of R2. 3.Q. "Lists considered harmful". but internally they need explicit connections not permitted in lists. produce a full relational applicative language. relation-definition . and we sought ways of reformulating the relational algebra so that the fact that a PL/I procedure was invoked would be transparent.f) soon was initially coincidental. extra structure to aid processing must be capable of addition. Perhaps this may in turn enrich logic programming. Two of these columns are identical . but we felt there must be better ways of solving the role inheritance problem. The basic syntax is.c) & W(p. and as a representation Lists have evsn intruded to aseist computation. as relational databases have been applied to engineering applications [eg.y.Y. Notation. the number of operations was reduced to four. initially this is not particularly significant but to invoke a complete later we will need 327 . and clearly one should be removed. where A is a column of Rl. CM 811. yeilding a result into PROLOGI [e. At this time (1975) applicative languages were beginning their regeneration led by. Uniting relations with functional languages leads us to higher order relations.A. and lists imposes one. pointed out to correspondence has.A.= typed-relation 'w' expression typed-relation = relation-name relation-type = "(I' variable 'I 'I type I".0 A RELATIONAL APPLICATIVE LANGUAGE X in The basic consists of relations. and one method he came up with replaced a relation by a PL/l procedure call. The critical limitation that this imposes is their For some applications dependence upon lists.C)*R2(P. and explores logic capabilities to match functional PWgramning Here I go beyond that paper to Programming.X.g. Indeed one could conjecture a paper titled. and this paper completes this cycle of development with an algebra of relations appropriate to general hierarchical relations. terminals have been included in quotes. DHT 821 has renewed my interest and the result is this paper. relations not in Codd 1st normal form. the appearance of two intervened.a. 831 A recent stimulating paper by Bob Kowalski [KOWA notes the equivalence between predicates (relations) and functions. for example Rl * R2 A=B A and B are role names." relation-type variable I1 @Itype) ")'I I expression operator expression expression Imodadic-op expression Irelational-constant Iuntyped-relation 111(11 expression @*)" = It*11 1 11+11 operator = II-11 monadic-op relational-constant = relation-type 11[11tuple (". but all too frequently they are inappropriate. books [HKND 80. An example of the generalised algebra is Rl(X. analytical manner. Relations as sets have no single ordering. There has been a recent move in this direction. extraneous structure which interferes with both must not be imposed. among others.product constrained by equality of values between matching domains of the two relationa. It there was a correspondence between the generalised join and functional application. Examples are shown in figures. The result is a relation of n + m columns (n = number of columns of Rl and m = number of columns of R2. The structure present in the problem must be capable of direct expression. but other things Then.a. GM 781.x. but which one? In the PRTV this was specified using a project operation. Relations may be complexly interconnected at the user level this interconnection may be considered associative. Applicative languages as they have developed today [as exemplified by the collection DHT 821 are still very much moulded in the LISP tradition. A relation is interpreted as a subset of the Cartesian product of the types. of course.g. both as a means of expressing the problem. AR 841. languaf3e involving expressions these relations. At the same time Stephen Todd was investigating how to ~~escape~~ from the relational algebra into PL/I. This was published at a conference in 1975 [HHT 751 together with an analysis of the restrictions the directional properties of cawed by The paper was presented in a highly procedures. struck me then that John Bachus [BACH781.l. to be motivated in the discussion below. A type is a set.*' tuple} ")" = "(I1 value [*'. and is not easy to read.@* variable) ")I1 The resemblance of this to the predicate logic formula Pl(x.F) which causes an equi-join on columns A and the two relations. but it was The us by Bob Kowalski. storage of information for For commercial data processing lists are particularly inadequate. lists are an appropriate structure. The result was a l'generalised** relational algebra (see example below) in which matching role names in a Cartesian Waturall' join caused an equijoin on these columns. Thus a major motivation of this paper is to move away from lists while still remaining an applicative language. An equivalence between relations and procedures became evident. LP 83.columns A and B. The notation in the relatlonal algebra used for the PRTV was a Cartesian product associated with a 'selection' which indicated the columns to be equated.I' value} ")" tuple = relation-name '*(" variable untyped-relation (ll.

0.Value = SINE(Angle.real.6428 0.a) l READINGS(p. is the key operation. permitted (though *w Complement is relative to the base type of the Composition relation.A) GOOD-READINGS t(l. 11 FIGURE 4 Relational FUNCTIONS Composition as Functional Application Sine R -> R Square-root R+ -> R f R->R f bwle) = square-root (sine (angle)) by placing define ANALYSIS(Pressure real.10). the usual set complement. Relation constants can be written as sets of tuples conforming to the relation immediately type preceding it. where the variables are not significant but position is.(8. The operations l precisely original 751.7. Result:real) SQUARE-ROOT(value. 0.3 (4.type-lattice to make our general. Angle real.result) in logic The interpretation of the operations programming are straightforward *AND + OR . 0. FIGDRE3 Example of Relation Composition as Selection FIGURE 1 &ample of Relational Composition as an Equijoin define GOOD_RANOE(Pressure. 1. SINE (angle real.3.45)) READINGS (Pressure. Logic. 90. a real) = MORE-READINGS (p. have been a library definition in Program* and we used an implicit Figure 3 to emphasise the use of composition as We will use arithmetic and logical selection. as an explicit set of "tuples" or intensionally by some rule such as a relational expression. I+' allows 328 . A relation may be represented either extensionally. composition also covers set intersection.value real) SQUARE-ROOT (Number:real.real 10 ). 1. ). 1-e Position in the parameters list is significant. could be allowed).3420 ) 70 . columns.10).1736 . l real) In relational databases.25). 0.(4. Value) ANALYSIS is ((1. The '+I allows functional composition.(8. ). Alternative interpretations of as Predicates in relations are. However.8660 0. 0. ). and selection as in Figure 3.a) CmCKED-RKADINGS is ((1. )) RELATIONS Functions are 'convertsd' to relations an explicit results parameter last. root F(Angle*real.5000 0. Angle) l SINE (Angle. 10.7660 0. ( 20. and rather than being defined could be extensionally.(8.9397 0. are indicated by coinciding variables in the Figure 1 shows an example. as in programming languages. Angle ) *real . and requires explanation. indeed should.real. Angle real) =angle<50 and Pressure>l.(3. 60.9848 l.2 (11.1 . 20 s 0. 70.ooo 1.1736 ). for this generalised composition operation that the algebra was developed [HHT FIGURE 2 Example of Relational Composition as Intersection MORK-RKADINGS(Pressure. [( 1. defined intentionally by a program. 10 .7. Value real) = RIIADINGS (Pressure. 20 I 4. 80.3420 ( ( ( ( ( ( ( 30. ( 1:::: 70 11 SINE Value) (Angle. From the these examples it should be clear that ?ables10 could be %irtuall'. 0.3.9.angle real) ((0.(1.2.45)) are composition alternation complement + relational relational relational Alternation is normal set union for relations of inhomogeneous combinations are not the same type. 50. 40. 1.3.6. is 10). and proceduut calls in programming languages.3. Angle real) 5 (Pressure*real. 45 1.(4.2.10).value) real.real.45) define CHECKED-RKADINGS(p.7.9397 ). composition covers the where the columns to be equated normal equijoin. The sine relation of figure 1 could. The variables are used for binding.0000 1. It was expressions informally in later examples.2. A real) = RiTADINGS(P. The type of a relation is the list of its parameters and their type. as shown in Figure 2.A)*GOOD_RANOE(P. real real r( 0. 20).NOT The interpretation in conventional (functional) programming languages is not so straightforward.O GOOD-READINGS(P real.15).

..as in Figure 1 given table of DATA values DATA(setting real..result) )*SINB(angle.0. for which special measures outside the framework of the theory have had to be taken. root RELATIONS real) G(angle real. However.) positional significance of these in principle.then.2).measure) One further operation is necessary. .x)*SQUARE~ROOT(x.. projection involves existential quantification.(g).. but if by programs would intensionally represented typically be only useable in a limited direction. constructs.string.).. An early attempt based on the PRTV experience. value real) SQUARE_RooT(Number real. the cardinality function which counts the members of a set. .size) *(set ( . we will have to consider further the specification of "type..(2.='. However..7). One could reasonably also allow extra columns on the left hand side.. size integer) size integer) 8) 41. result real) = ((NON_P1RG(value)*SQUARE_ROOT(Value.0)~.. and "if .case. .s papers [CODD 701. (((FRED).(l0~~.(~~S~L)..(b).. Thus in Figures 4 and 5 the intermediate "value. However the seeds of it have recurred in the need to produce totals and subtotals.measure real)=(. and the full relation must of course be represented intensionally. for it allows functions to be used "backwards. to make the relational expression identical in semantics to the functional Programming expression. expressed both in the programming notation of Henderson [HKND 801 and in the relational notation. FIGURE 6 . but in the next section will see how to define this function recursively.(~~~(d~:~~~.angle real) = DATA(setting.(~)). (((1..13. 4. lists its columns..(0. We now consider relations where the columns themselves may contain relations.8)}. FIGURE 7 Example of Higher-order given CARDINALITY (set relation.projection. interpretting these as Cartesian products extending the relation defined by the right hand side of the definition. of around the theory thoroughly which was very representations This characterised in the 1975 paper [HHT 751. As observed by Codd [CODD 721.invertibility. (((0.(LISP)~)) SIZE_oF_SET 1s t(2).3)... (JOE)~ .))~(~(0. value real..) t. The tabulation only considers a few examples.(f).value) An example of the use of SINE to compute arc-sine is shown in Figure 6.. Up to this point we have assumed a base set of types like "real. This IS the Rather than of relational algebras.. ... The relation being defined and placed on the left-hand side of .. thereby giving the relational algebra the power of the first order predicate logic.0. thus determing the define SIZE~OF~SET(size integer) = CARDINALITY(set. Now in relational databases this has been depracated ever since the first of codd.(PASCAL).0 HIGHER ORDERRELATIONS FIGURE 5 . .Using a table of SINES as Arcsine =I~~(a).Conditional FUNCTIONS Applicative Expressions R -> R Sine R+->R Square-root g(angle)= (if x> 0 then square-root(x) else square-root (-x) where x=sine(angle) ) SINE (angle real.value) or = ((value~O)*SQUARE~ROOT(value.integer..(3.0... All three together Figures 4 and 5 show allow logic conditions. (I(FoRTRAN). ..1. but now * 329 . to handle this.~). Figure 7 shows an example..result) + (value<O)*(x=-value)*SQUARE-ROOT (x.0. have a special operator for this. was made by Hitchcock [HITC 761.else..effectiveness.result) + NEG(value)+NEGATE(value. functional examples. (Kowalski [KOWA~S] calls this . in relations.01)...1.measure real. a: 2).. our composition operator is far more powerful than traditional functional composition.. . we will make it a property of the definitional equality .0.real. all variables on the right-hand sids should appear. if some are omitted. This observation then leads to a further level of . 1 SINE .result) )*SINE(angle.. Now tabular functions are clearly able to be used bidirectionally.(ALDOL).=.(5)) To make this and other definitions of higher order relations acceptable. Cardinality (. Vital for any functional would be theory the relational programming interpretation of applicative language.(4.alternatives to be combined as in .56. this means that they are projected out. can be omitted. At the moment we will assume some built-in function outside our programming language..measure)*SINE(angle.) define ANALYSIS(setting.

FIGURE 10 Recursive Relational fact(n) = if Definition of Factorial For this we will extend the relational-definition so that the columns of a relation and operation.item integer...).cost..cost real) ((BLOGG_BROS.. operation of SQL [ABM 76) necessary for sub-totalling.orders(item.11-*~" I "(. Figure 7 and 8 have used the notation we intend to employ....The Higher-order given TOTAL (relation relation.06). but preceding the type description by a prime tupletype 5: .cost)) l TOTAL(orders.. relation is not necessary. but has been included for clarity. This simple operation for converting between orders of functions provides a very powerful file language.(.. to write compilers and similar.x) Note y+l=n is used to compute y=n-1.).Cost...r integer) = (n=G)*(x=l) + (n>O)+(n*x=r)*(y+l=n)*FACT(y.. but that is too restrictive for higher order relations like TOTAL shown in Figure 8 which must sum the values of one column but does not care about the other columns. Recursive definition of relations. Higher order relations provide the ability to .real) = PURCHASE~DBTAILS(supplier..*.item. and vice versa. FIGURE 9 Conversion from first-order to second-order given PURCHASE~DETAILS(supplier~string.. that has not been my motivation.. We will only use this operation in the form shown there..57.total-cost real) = TOTAL(orders (.42. TOTAL (.item. The syntax is fullrelationtype = relationtype variable type I ( 11 .*= identifier We PURCHASES-SUMMARY (supplier string. Note that this is different from the kind of changes featured by LISP which changes program text.. The intermediate . perhaps as a lattice of types...cost) real)) The syntax for type is then = simpletype type I fullrelationtype I tupletype simpletype . where a first order relation is converted to a second relation with only one column of However a general operation could be relations.GROUPBY.. notation to indicate optional columns.number. and provide a conversion could theoretical basis for languages like EXPRESS [SHTG 771..orders (item integer. higher order relations. The operation of Figure 9 is the .integer. as has been done in Figures 7 and 8.. 5..21)..cost = PURCHASES(supplier. We have already defined the type of a relation as the list of the types of its columns..price) l (cost = number l price) PURCHASES-BY-SUPPLIER (supplier string.1. in the sense that by suitable modify relational expressions the transformations defined by a relation can be changed.[(1. We can write relations as column values within relation constants...)...programs.total-cost) using . However we will need general mechanisms for converting given relations into ..equivalent.real) define PURCHASES(supplier string..43)))) ~RDER_SURWARY ((BL~Gc-BROS.total-cost) *(supplier string... However. 100. and my notation has not been aimed at that. 330 . the factorial function.cost. Figure 9 shows this use. defined. readily..)" will also allow columns to contain individual tuples.NUMBER real.. inspired by the methods of functional programming. its subrelation can be regrouped as shown in Figure 9.price.order (item. and denote their type in the same way as relations. if any. Figures as components 11 and 12...0 only RECURSIVEDEFINITIONS will pick out the components of a tuple the usual dot notation typecomponent = tuplevariable columnvariable FIGURE 8 ... fullrelationtype We digress from our main argument..total real) define ORDER~SUMMARY(supplier string.PURCHASE. Of course here we could represent text by suitable relationships and do the sort of manipulations practiced in LISP... treating this informally while recognising that this should be properly defined..total~cost~real) = PURCHASES_BY_SUPPLIER(supplier.must extend this to include relations themselves. follows very Figure 10 shows that overworked example.(32.70)) IS Examples involving tuples appear in section 4.(127.item integer. since it requires a very careful definition that would n==Othen 1 else n*fact(n-1) FACT(n integer. number integer.. We will use a . though it will not be done here.

residue (..). An entity-relatlonshlp systems analysis [HOT 76.element EMPTY(set (. For example. We want to produce the reports PRODUCER_RXPORT PURCHASE-REPORT with columns (name string. The NON-SINGLETONrelation the relative complement of SINGLETON with the elements projected out. We could choose to treat relations as sequences and follow the practices of LISP.element I(.. This is the counterpart of the car. data The problem domain chosen is sclentiflc commercial problems have been avoided analysis because they typically involve update.elem.. otherwise for a non-empty relation an element is chosen and the "number" column of that element IS added to the sum of the residue.).. The choice function applies to relations of arbitrary type.subsetl (.)) (.). 6. and the average price These figures should be broken down per kilogram.elem) FIGURE 11 The Choice Function recursive must be careful to distinguish define which from equalities definitions. TOTAL is defined recursively to sum the values on the column %umber" in the given relation.sum real) = EMPTY(relatlon)*(sum = 0) +(-RMPTY(relation))*CHOICE(relation.. FIGURE 12 The Split Function and another definition of TOTAL given SPLIT(set (. For singletons the sum is the value of the NURSER column.. and then these parts into parts and so on recursively until atomic parts are encountered.. This approach 1s similar to Williams' tree function-composer [WILL 82). other For relations the result 1s the sum of the TOTALS for the two subsets selected by the SPLIT relation..number real.).subl. we need to be able to recurse on the relations themselves.. the singleton relations and the elements contained is defined as in them... average-weight kilograms. A first method is the "choice" function of set theory.res) l TOTAL(res. We also need a way of stopping the recursion.)) define TOTAL(relatlon (.numbBF+sum~res=sum)". We will see two alternative methods of approaching this. being sold at the A survey is being made pigs It is required to find out the local meat market. 331 .sum real) = SINGLETON (relation.sumi!) l (suml+ sum2rsum) + EMPTY(relation)*(sum=O) where NON-SINGLETON(re1 (..)) define TOTAL(relation (. Given a set...-price sterling-per-kilogram) given CHOICE(set ( . but before we can do that.Recursive definitions will be most useful in the definitions of higher order relations.element)*(element... in the same way that LISP and its derivatlves recurse on list structures.. Figure 11 gives an example.. . total-weight averag.SINGLETON(rel. a properties of the relation. and the handling of time and update is outside the scope of the study so far..))= We . If the relation is empty the sum is zero.. treatment of such cases is outside the scope of this paper.. To stop the recursion a method of testing for a singleton is necessary.number real.number=6um) + NON SINGLETON(relation)+SPLIT(relation.. average weight of carcases.. weight variance kilograms. What we need is some method of breaking a relation into parts.). where a second definition of TOTAL is given.)) '(. and a function for testing for the null set is assumed.subset2 SINGLETON(set (. but relations are sets and no ordering may be natural.sum~res)+(elem.number" to indicate the binding between the result of the CHOICE relation and the addition relation ~~(elem. A device like this has been used by Hitchcock [HITC 74).b X) = R(b X. though the relation.. Note that the SINGLETON relation has columns of kilograms..sub2) "TO~AL(subl.). In these the columns "id" are the surrogates of [HOT 76).a X) This is a higher and fits into our theory. cdr and null functions of LISP.number+sum~res=sum) Note we have used the notation VVelem. An example IS shown in Figure 12.. it chooses an element and returns thus together with the reeldue (the set less the chosen element).. relation could be defined as symmetric by the equation order R(a X. by producer and by purchaser.0 A SIMPLE gXAWPLE and the definition of TOTAL In this section a very simple example is chosen to illustrate the language developed in this paper... CHEN 761 shows three entities PRODUCER CARCASE PURCHASER and one relationshlb SALES as shown in Figure 13.)..suml)*TOTAL(sub2.. The second method is a "split" function which devides the set into two arbitrary disjoint sets whxh are non-empty if that is possible. For empty relations the result IS zero (the long stop for empty arguments to TOTAL).

..number real... nevertheless.date required are grade) Note that further facllltles would be required to control the format of the reports arranging presentation sequence.FIGURE 13 . the use of the functions TOTAL. statistics the logic programming the correspondence with a higher-order relatlonal algebra may suggest a way of moving logic programming into higher order logics.)..(.. Hopefully through this rapprochement to lead these technologies will become integrated to effective really implementations of non-procedural manipulating large languages volumes of data. Logic Programming.. The notations developed here are very compact and potentially difficult to At best they could serve as an abstract use. to fruitful The correspondence of these two with functional programming languages is the interesting one...kilograms.purch.tsq-res) *(elem.)... TOTAL-SQUARED and COUNTcould be optimised to require only one traversal of the data.).res) l COUNT(~~~. .).price)) l TOTAL(prods. though neither of the approaches allow general higher order operations. This needs development. The seeds have been there in the database literature for some time particularly in the work of Buneman [BF 79. average~ice.g.0 CONCLUSIONS id. as desired by Kowalski [KOWA831.weight_variance) '(var-sq = tot-wt-sqd ...num) l (average_pricentotalJrice/total~weight) *(average-weightitotal-weight/num) l square_root(var_Bq. GM 80).. for example.).elem. For are PRODUCER~RKPORT(producer_name string. and count these and sum these over carcase weight. relations.C~~~)*(CI'W + 1 = count) Definitions of Reports What I have done is develop a rapprochement between Relational Algebras. and their use. Kach of these has its own implementation technology.. sterling)) 332 .weight.... and weight-squared.el. wishing to advance functional programming through the less facilities restrictive offered binary by The final facilities are.).weight.. Perhaps a dual view withln a single system could emerge.carc.totalgrice) l TOTAL-SQUARED(~~~~~(..(. layout.prods (weight.total-sq*real) = RMPTY(relation)*(total-sq=O) + (-EMPTY (relation))*CHOICE(relation. higher-order The required. What I have not entended to do is to develop yet another database system...number.price.carcase.real.count integer) = EMPTY (relation)*(count=O) + (-EMPTY(relat~on))*CHOICg(relation... weigh-variance kilograms..tot-wt-sqd) *COUNT (prods (. therefore.producer-name)* l SALES(prod.. average-weight. appealingly similar and his paper makes an excellent complement to my discussions. syntax.total-weight) l TOTAL(prods.aver-e-weight**2)/(num-1) where PRODUCER GROUP(producer name. are shown in PRODUCER(producer id.. ....).date) *CARCASE(carc. development The of the correspondence with functional programming has enriched relational algebras.residue) *TOTAL-SQUARBD(residue. and from these compute price. While elaboration of a concrete syntax on the relational model may appear attractive with its tabular view of data. The correspondence between relational databases and logic has been known for a long time and led results [e.residue) l TOTAL(residue.Sales analysis Entities are of Pig Market relations required.) as f% PRODUCgF-REPORT To produce these we need to gather together all the sales of a particular producer or purchaser. prods (weight kilograms.weight. total-weight kilograms. and Functional Programming. 7. with the concrete syntax containmng many more operations to enable ease of use and. A recent paper by MacLennan [MACL 831 takes a relational view of functional programming.price = PRODUCER(prod. so that.total real) = KMPTY(relation)*(sum=O) + (-EMPTY(relation))+CHOICE(relation. date) relations TOTAL(relation (. I believe the way forward will be through functional programmingusinga functional view of data.. Note also that efficiency has been assumed to be left to the implementation.name string) CARCASE(carcase id.weight kilograms.elem.price.grade) PURCHASER REPORT(purchaser_nanre string..sterling~er-kilogram) = PRODUCER_GROUP(producer_name. etc.purchaser price*sterling..string.sum-residue) l (elem.number+*2 + teeres = total-sq) COUNT(relation (. Figure 13..name:string) Relationships SALES(producer Utilities are id. BFN 821 and Shipman [SHIP 811.grade PURCHASBR(purchaser id..id. and in particular moved away from a lot of the constraints imposed by first normal form. accurracy of use.number+sun~residue=total) TOTAL-SQUARED (relation ( . His motivation is very different from mine.

House1 B. 13. Gray J. and Todd S.P. "A Relational Large Shared Data Banks" CACMVol... too. Languages. Pages 201-220. Editor GM. "Predicate logic as a language" in Information wogr-iw Processing 74.. Report UKSC-0051 May 1974. Vol. HHT 75 Hall P. In implementation. 18 No. Pages 140-173.R. BCS System" In Database 83 Conference %lnctiona1 Henderson P. Vol..C. SHIP 81 Shipman P. "The Functional Data Model and the Data DAPLFX" ACM Language Transactions on Database Systems. on Database Systems.2 June 1977 Pages 136-171. Frankel R.A. King W. states inherent in most formal approaches to JONE 801 1s not judged adequate. "System Developmentw Prentice Hall 1983. and something more along the life history approach of Michael Jackson [JACK 831 is expected to be the fruitful approach. Implementation" Application and Normal ABCE 76 BACK 78 BF 79 BFN 82 CHEN 76 CM 81 Prentice-Hall 1980. Rustin) 1972. California.. Frankel R. ACM Trans Database Systems. "User Extensions to the Peterlee Relational Test Vehicle". Boston May 30th .J. R.J. HOT 76 Hall P.L. 164-186.One particular advantage of the relational view was its neutrality on "dlrectlon@@. and Minker J. March 1976.F.H.A Buneman O. Turner D. MACL 83 MacLeMan B.S. **Programming in Prolog" Springer 1981. Vol. Chen P. 1975.W. its and "Functional Programming Press.W. Pages 377-387... Relations can functions engender a be used in any direction. Taylor R. Mehl J.. Int.. to Database Approach Relational Management" ACM Transactions on Database 1. Vol. "An Buneman P.D. Management of Data.A. Ghosh S. HITC 74 Hltchcock P.P. "Can programming be liberated A functzonal from the von Neumannstyle? CACM.E. Hitchcock P.F.A.. 1. Model of Data for Codd E. ACM.C.A. Cwlett J. No... Nlkhil R. and T&d S.J..W. %ukiamental Operations on Relations" IBM UK Scientific Centre. North Holland 1974. No. perhaps.W.. *'Complex Objects and Their Use in Design Transactions". Pages 52-57. but. NiJssen. "Peterlee Relation Test a system overview" IBM Systems Vehicle Journal. Vo1.W.Y..3 August 1976.F. computing [e. June 1976 page Systems. Base sublanguages*' In Data Base Data Prentice Hall. "EXPRESS aData Extraction.E. A Rigorous Approach". "Note on the FP style of Functional Programmingw page 73-102 in DHT 82. Database Week. 2nd VLDB Conference. New York 1979.. 1976. tbe conatraln him.. neutrality of relations can be an advantage. "Logic and Gallaire H.P. P. SHTG 77 Shu N. and Watson V.P. Pages 569-574. April 1984. Systems (Ed. Application6 II Cambridge University 1982. JACK 83 Jackson M.V. no. llICL's Data Dictionary Gradwell D.0 AB REFERENCES 84 Abitebout S. In Proc.. March 1981.. Pages 36-45. functional query language *I. "An Algebra of Relations for Machine Computationw.g. 7 No 2 June 1982 pages Systems. No 1.. and REStructuring Systems'* ACM Trans. to appear. Brussels 1976. Henderson P. 1. TODD 76 Todd S. page 9-36. HITC 76 Hltchcock P.D.V. Conf. 1979. "Relations and Entitiesw in Modelling in DataBase Management Systems. Pages 65-98. "FQL .J. "Software Development. "Relational Completeness of Codd E. Griffitha D.2. Vol. 97-137. Processing. ACM SIGMODAnnual Meeting. Third ACM SIGACT-SIGMOD Symposium on Principles of Database Systems. 2. HCCR 80 McCracken D..W. Clocksin W.. Programming.R. KOWA74 Kowalskl R. No. The next step in this line of development of databases must be the incorporation of update and The usual approach of before and after time. LP 83 Lorie R. Jan. 8. G.. Blasgen M. Second ACM Symposium on Principles of Programming Palo Alto. and Lum V. and Bldolt N. "Logic Programming" Invited Paper for IFIP 83. May 1983.P. WILL 83 Williams J.J. 6. Chamberlin Eswaren K. JONE 80 Jones C. KOWA83 Kowalskl R." August 1978.A.6.P.J. Databases" Plenum Press 1978. 15.P-S "The Entity-relationship model Towards a unified view of data".. McJones P. style and its algebra of programs. IFIP/North Holland. 3 March 1983. Prentice Hall 1980. Backus J.B.A.N . and Melllsh C.M.L. l'Overview of Relational Programming" SIGPLAN Notices. Lorie R.. and Plouffe W. in Engineering Applications. Darlington J.P. ACM Sigmod.. Vol. CODD70 CODD72 DHT 82 GN 78 GRAD83 HEND 80 333 . "Non Flrst Represent to Form Relations Hierarchically Organised Data". ‘*A Guide to NOMAD for Applications Development" Addison-Wesley 1980. Astrahan M.A. Putzolu 'System R Wade B. June 1970. very strong direction from domaln to range which ln the end can help the user. No. Pages 225-232. Traiger I.F.June 1.. for Database Technique Implementation on Database Query Languages" ACM Trans.