Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

thepler (6873)

thepler
  (email not shown publicly)
http://www.employees.org/~thepler

Journal of thepler (6873)

Wednesday August 06, 2008
07:43 PM

the relational model

Some ideas have been swimming around in my head ever since I read Database in Depth by C. J. Date. I finally put some of them down in code.

http://www.employees.org/~thepler/Romo-0.01.tar.gz

I'd be glad to take any feedback on this proof-of-concept.

There were several potential directions to go with this. I just ended up picking one that seems to work for the time being. It's all pretty rough. One of my objectives is to make something that is satisfying from both the relational and object-oriented perspectives. The hypothesis being that the object-relational impedance mismatch is a myth.

A couple notes... There is no SQL. There is no persistence. Remember, the relational model != SQL.

The book spends some time talking about "value types". I'm no expert on type systems but I think these map to "immutable types" in the Perl 6 spec. And these get involved with === and WHICH. Since I'm doing this in Perl 5 and Moose, I made up a way to do === and WHICH. So === is spelled is_identical, and it's a method instead of an operator. And WHICH is still spelled WHICH, but it's ->WHICH instead of .WHICH of course. My attempt at doing this is in these modules: Romo::Identical, Romo::WHICH. I'm pretty sure Perl 6 will not be implemented this way (using roles), but it's working so far for my purposes. Feedback quite welcome.

If you're familiar with "Database in Depth" you may want to look at t/01.database_in_depth_example.t. There's some cruft, but it makes "types" and relations for the running example in the book and performs some relational operations on them.

There are questions that I still have about the current approach to types/classes. To some extent, this is a learning exercise for me, so I intend to push things until I hit some kind of wall. I'm also being conservative about what can happen, and throwing exceptions to enforce it until I figure what out the implications of loosening those constraints are.

I haven't been looking at optimizations yet either. I'm trying to get the interfaces and functionality correct before worrying about speed.

I've been using Muldis for reference. In particular, the names of the methods in Romo::Relation are taken from there.

Random thing on my TODO radar:

  • relation variables
  • keys
  • databases (tuple whose attributes are all relation or database typed)
  • make relations lazy and use iterators