A Relational DBMS in under 1000 lines of (Haskell) code!

In thinking about a data storage model for a web app I wanted to develop, and in finding Haskell so concise and expressive, I wondered if one could write a relational DBMS in Haskell in under 1000 lines of code. The answer appears to be yes!

Features:

  • non-destructive-update Haskell DBMS (can use a
    relational database without escaping to the IO
    monad!)

  • supports user defined types
  • supports user defined relations and functions
  • command pattern structure for write-ahead logging
  • Inner,Outer,Left,Right joins on arbitrary
    (user-defined) relations (not just “=”)

  • in-memory/in-process means no disk/marshalling overhead

Risks:

  • functions/aggregates not yet implemented e.g.
    (a<b+c) or (a<max(b))

  • no performance testing — joins expensive!
  • no proof of correctness
  • written by non-academic new haskell developer
  • Not SQL. No Sockets. — should be part of the
    app wrapper used to maintain consistency!

License: GPL

Note: I am an expert neither in Haskell, nor in
relational databases, nor in
relational algebra/set theory/category theory. So
comments/suggestions/recommendations on any aspect
of this code are welcome.

Comment on Haskell: WOW!!!!!! I basically wrote
this without testing just thinking about my
program in terms of transformations between types.
I wrote the test/example code at the end and had
almost no implementation errors in the code! The

Download Source

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: