[elephant-devel] questions about persistent classes

Ryszard Szopa ryszard.szopa at gmail.com
Wed Apr 16 00:37:41 UTC 2008


Hi,

I've started using Elephant and I must say I am really surprised how
easy and nice to use it is. However, there are some areas where I feel
a bit lost, and I couldn't find the answers in the manual. I am using
Elephant 0.9.1 with a BDB backend.

1) What is the right way of doing something similar to a UNIQUE
constraint in a relational database? The solution on top of my head is
to write a method for `initialize-instance' that will check the
existence of an object with the same value as the provided for the
unique slot (which should of course be indexed), and raise a condition
if yes.

2) What is the right way to do many-to-many relationships? At the
moment I have slot with a pset, and add object A to the pset of object
B and vice versa, in a transaction.

3) How do I implement something to do efficient (i.e. not O(n)) LIMIT
and OFFSET queries? I was thinking of maintaining a counter (my
intuition would be to use a class allocated slot, but I think that
class objects are not serialized---am I right?) for classes where I
need it, and using some method to update it. For decreasing the
counter my candidate is drop-pobject, for increasing
initialize-instance, but I am not sure about it (btw Elephant
complains if you try to trace `initialize-instance').

4) What is the intended use of `add-class-derived-index'? I must say
that the documentation isn't very clear about it (specially figuring
out what is a valid `derived-defun' wasn't trivial). Tight now I think
I am supposed to run it once (it complains about a duplicate index if
run a second time). This isn't exactly handy, because I would prefer
that defining a derived index to left a clear trace in my code. Right
now I am calling it wrapped with `handler-case'.

Finally, how stable is the unstable version of Elephant and what are
the most important changes that have already been implemented? I am
specially interested in the query language part.

Thanks in advance,

    -- Richard
-- 
http://szopa.tasak.gda.pl/



More information about the elephant-devel mailing list