Re: Tree constraint in the adjacency graph model
Date: Sat, 25 Jun 2005 10:34:21 +0200
Mikito Harakiri wrote:
> Stefan Rybacki wrote:
>>>>Consider adding these constraints: QuoteNo as key,
>>>>and PreviousQuoteNo as foreign key to QuoteNo.
>>>>Only now we have the intended tree-consistency.
>>>>The circular states mentioned above are inconsistent with the
>>>>constraints, and I can't add these values by hand or by algorithm.
>>>Oops - still not good enough.
>>It should be good enough for an insert but not for an update, or did I
> Why QuoteNo as unique key alone is not good enough? And, more
> important, why it's not good for update?
Look at this:
The following table is given:
quoteNo (PK) previousQuoteNo (FK->quoteNo) 1
2 1 3 2
All is fine, but if I do this
UPDATE table SET previousQuoteNo=quoteNo
UPDATE table SET previousQuoteNo=3 WHERE quoteNo=2;
So you can see the FK constraint allows you to create cycles
> With QuoteNo as unique key no child having 2 parents is allowed, so
> that the only structures that escape this constrait are cycles.
correct, as stated above.
> disallow cycles requiring that at least one node should either have 2
> children or no children at all.
That won't help much, since it still allows cycles and but it doesn't allow a tree like this:
Or did I get you wrong?
Received on Sat Jun 25 2005 - 10:34:21 CEST