|Think about Loose Coupling|
Set-Theoretical Database Interfaceby awwaiid (Friar)
|on Feb 19, 2004 at 09:21 UTC||Need Help??|
So here is something I've been toying with a bit. I've never quite been satisfied as a programmer of databases... when wearing my database designer hat I get to think in terms of relational set theory. When I put on my programmer hat I get to think in terms of rows. No fun at all. I decided that it would be Cool to let my programmer-hat-person get a better view of the database. This is a little snippet from my work-in-progress toward this end.
The schema here has three tables: person, has_book, and book. The person table holds people and the book table holds books and the has_book table holds pointers to a person and a book. You'll note that the code does not mention the has_book table at all -- that is because the path from person to book through has_book is inferred from the schema.
This looks like the following when run (two executions to demonstrate the database update -- oh, and Joe has no books, BTW):
The code to make this happen includes such strange things as an object who's blessed thingie is a tied hash back to itself so that it can detect changes to its own hash elements... something which would not work out so well (or not be quite so possible) in just about any other language I can think of, thats for sure!
So what do you think? Cool Use for Perl? There is a lot to be done here and a lot more ideas for this project which I will eventually implement. Please tell me your ideas!
See http://thelackthereof.org/wiki.pl/SetDB for full code and eventual updates.
UPDATE: Fixed some code a bit.