Re: Tree constraint in the adjacency graph model
Date: Sat, 25 Jun 2005 10:34:21 +0200
Message-ID: <3i4j8cFhel47U1_at_individual.net>
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
>>forget something?
>
>
> 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
or
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.
>Then,
> 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:
1->2->3->4
Or did I get you wrong?
Regards
Stefan
>
Received on Sat Jun 25 2005 - 10:34:21 CEST