Re: Relationships between view classes

Nicolas Neuss <[email protected]> Mon, 10 May 2010 09:36:26 +0200
Newsgroups gmane.lisp.clsql.general
Organization KIT Karlsruhe
Message-ID <[email protected]>
Warren Lynn <[email protected]> writes:

> Hi,
>
> I am a newbie to both CL and CLSQL. It seems to me that CLSQL does not
> provide much support to manage the relationship (one2many, many2many
> and etc) between view classes. What I mean is, take the classic
> "company/employee" example, if I have a company instance, can I just
> add an employee instance to the company instance's "employees" slot,
> save the company instance, and the database will be updated to reflect
> the relationship (or the reverse, just set the employee's "company"
> slot to an company instance without fiddling with all those primary
> keys)? For many2many relationship, can CLSQL automatically generate
> and maintain the intermediate mapping table?
>
> Basically, I am missing those nice features from Django data model. I
> am intereted in CL because I am convinced that CL can express high
> level abstractions more elegantly than other languages, so I am
> puzzled that CLSQL is at such a low level, although it seems well
> designed at that level. If CLSQL's scope is intentionally limited to
> that level, can anyone give me some pointers to CL packages/systems
> that can handle higher level data model relationships, based on CLSQL
> or any other SQL based database backend.  Thanks a lot.
>
> Some side notes:
>
> Right now I am not considering things like Elephant because its
> complexity scares me and I am afraid if I get a corrupted DB I will
> never be able to recover it (with SQL DB at least I can look at the
> raw table and fix it by hand). Plus it does not compile on my system.

I think that you are right here.  It would be nice if we had a layer
atop of CLSQL which would provide references and lists of references.  I
have attached a first attempt which I use and which defines
automatically indices which can be referenced in slots of other classes.
Unfortunately, it is far from perfect (especially, no lists of
references and deletion of references when instances are deleted), but
at the moment it serves me rather well.  If someone can improve on it,
this would be fine.

Nicolas

P.S.: The nicest solution might be AllegroCache (but: no seperate access
using SQL) and the second best Elephant (but: I am not sure how well
Elephant supports SQL databases - up to now I have only used it with
BDB).

_______________________________________________
CLSQL mailing list
[email protected]
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
clsql-enhancements.lisp (application/octet-stream, 7.8 KB) - not displayed