Re: Quote of the Week

From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 24 May 2004 19:12:03 -0700
Message-ID: <8a529bb.0405241812.47af114f_at_posting.google.com>


jcelko212_at_earthlink.net (--CELKO--) wrote in message news:<18c7b3c2.0405190833.29fa8269_at_posting.google.com>...
> >> [How would you compare two of these organization structure
> relations for equality?] Aggregated total? <<
>
> I never thought of that! I feel like an idiot! Why do you keep
> coming up with good ideas after the book is printed??
>
> But there is no need for recursion to sum the subtrees:
>
> SELECT O2.emp, SUM(S1.weight)
> FROM OrgChart AS O1, OrgChart AS O2,
> Salaries AS S1
> WHERE O1.lft BETWEEN O2.lft AND O2.rgt
> AND O1.emp = S1.emp
> GROUP BY O2.emp;
>
> >> Finally, tree structure are identical if they have identical weight
> at the root. <<
>
> Not true;

My bad.

> consider the set of weights (1,2,3,4)= 10 which could be
> split up as ((1,4), (2,3))= 10 or ((1,2,3),(4)) = 10. What we need
> is two tables with the sums from the trees which are identical, weight
> for weight. Easy enough:
>
> ((<<above query for Table A>>) EXCEPT ((<<above query for Table B>>)
> IS NULL
You meant symmetric difference and "IS EMPTY", of course.

Although, in principle, it is possible to repair the original approach (because there is a bijection between [multi]sets of integers and integer numbers, so that comparing [multi]sets can be reduced to comparing their integer encodings) your solution looks better from practical perspective. Received on Tue May 25 2004 - 04:12:03 CEST

Original text of this message