On 4 Jun 2009, at 2:48pm, Mark Hamburg wrote:

> One of the questions that I believe was raised but not answered on
> this thread was how to make sure that you don't have circular
> relationships particularly given that SQLite isn't good at scanning
> the tree.

I don't think it can be done without either

(A) Knowing you're going to need to do it at the start or
(B) Programming (i.e. logic outside of SQL)

What you generally do is have a column called 'ancestors' and build up  
a long string with the ids of all the node's ancestors in.  Something  
like ';234;564;12;3335;23;525;'  Then each time you set a parent-child  
relationship you check to see that the child's ID is not in the  
parent's ancestor field.

I haven't looked at exactly what triggers SQLite allows.  I think this  
could be possible with it, but it might not.  It does, however, make  
use of recursive triggering and this may itself be a problem.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to