functional database
functional database
(database, language)Databases would seem to be an inappropriate application forfunctional languages since, a purely functional languagewould have to return a new copy of the entire database everytime (part of) it was updated. To be practically scalable,the update mechanism must clearly be destructive rather thanfunctional; however it is quite feasible for the query language to be purely functional so long as the database isconsidered as an argument.
One approach to the update problem would use a monad toencapsulate database access and ensure it was single threaded. Alternative approaches have been suggested byTrinder, who suggests non-destructive updating with shareddata structures, and Sutton who uses a variant of a PhilWadler's linear type system.
There are two main classes of functional database languages.The first is based upon Backus' FP language, of whichFQL is probably the best known example. Adaplan is a morerecent language which falls into this category.
More recently, people have been working on languages which aresyntactically very similar to modern functional programming languages, but which also provide all of the features of adatabase language, e.g. bulk data structures which can beincrementally updated, type systems which can be incrementallyupdated, and all data persisting in a database. Examples arePFL [Poulovassilis&Small, VLDB-91], and Machiavelli [Ohoriet al, ACM SIGMOD Conference, 1998].
Query optimisation is very important for database languagesin general and the referential transparency of functionallanguages allows optimisations which would be harder to verifyin presence of side-effects.
[Trinder, P., "Referentially transparent database languages",1989 Glasgow Workshop on Functional programming]
[Breazu-Tannen et al., DBPL-91].
[Poulovassilis, VLDB-94].