Re: SQL, related records (quotes)
From: Stefan Rybacki <stefan.rybacki_at_gmx.net>
Date: Fri, 24 Jun 2005 23:46:42 +0200
Message-ID: <3i3da4FjmkshU1_at_individual.net>
>
>
> Values like
> QuoteNo PreviousQuoteNo
> 3 6
> 6 3
>
> or just
> QuoteNo PreviousQuoteNo
> 3 3
>
> are possible, so no tree. The columnnames suggest the OP does not
> want this to happen. They don't help to prevent these loops though.
Date: Fri, 24 Jun 2005 23:46:42 +0200
Message-ID: <3i3da4FjmkshU1_at_individual.net>
mAsterdam wrote:
> Jan Hidders wrote:
>
>> Stefan Rybacki wrote: >> >>> timpea_at_gmail.com wrote: >>> >>>> Hi, >>>> >>>> I have a website that users can request quotes, and a user may also >>>> make a new quote that links to a previous quote. >>>> >>>> QuoteNo PreviousQuoteNo >>>> 1 >>>> 2 >>>> 3 1 >>>> 4 3 >>>> 5 4 >>>> >>>> If i request quoteNo 3 i want to have a list of all the related quotes. >>>> >>>> >>>> RelQuote >>>> 1 >>>> 3 >>>> 4 >>>> 5 >>>> >>>> Is this possible with a SQL statement? or would i be best doing a loop >>>> in asp and many requests? >>>> Thanks Tim Pearson >>>> >>> >>> Try the nested sets model. >> >> >> Are you sure the relation describes always a tree?
>
>
> Values like
> QuoteNo PreviousQuoteNo
> 3 6
> 6 3
>
> or just
> QuoteNo PreviousQuoteNo
> 3 3
>
> are possible, so no tree. The columnnames suggest the OP does not
> want this to happen. They don't help to prevent these loops though.
That is true but these are inconsitent states. Its clear that you can create those table values by hand but think about it in algorithmic way:
Same for the second example.
Regards
Stefan
Received on Fri Jun 24 2005 - 23:46:42 CEST