Re: beginners querying question

From: Jan Hidders <hidders_at_REMOVE.THIS.win.tue.nl>
Date: 27 Aug 2001 21:18:04 GMT
Message-ID: <9medec$psc$1_at_news.tue.nl>


Niko Schwarz wrote:
> Jan Hidders wrote:
>
> >> grp[|pricing ::= MIN(pricing)](Articles) join[pricing](Articles)
> >>
> >> is this possible? or reasonable? isnt there another... you know, a cuter
> >> way to do that? if this would work, it would seem to me like the dirtiest
> >> hack on world =)
 [...]
> > But in most extensions I've seen your solution is possible, and I would
> > also say that it is reasonable. Keep in mind that the join is an
> > abstract operation that is not necessarily implemented with a nested
> > loop. So the expression does not imply that you are iterating over the
> > same table twice. I assume that is why you feel it is a "hack".
>
> umm, i used the join only, because i did not figure how to use the result
> of the grp (the computed pricing field), as a variable.
>
> meanwhile i read on, and i found an example that tells better the part i
> dont understand:
>
> | article | pricing | stock |
> ---------------------------------------
>
> thats the three domains in the tupel, now: i want all the articles, that
> have a higher pricing than the most expensive article in stock 7.
>
> what i would have to do now is to save the most expensive item in a
> variable, and this does not seem to be possible by the notation my book
> gives.
>
> after some hard tries, i thought a work-around might work about the "full
> outer join".
>
> the thing ive written down looks now like this, but this time im almost
> sure it does not work:
>
> sel[pricing > max_pricing] (
> (grp[|max_pricing ::= MAX(pricing)](
> sel[store = 7](Article)
> ) join*[]*(Articel))
> )
>
> the idea: i copy the max pricing to any tupel of the relation and then i
> can compare in a simple sel statement.
>
> the problem: ive got no idea if an outer join really works like this, and
> to be honest: using a true variable would look much more performant to me...

That's not really the outer join but a cartesian product. Outer joins are only relevant if there are NULLs involved. I assume that the cartesian product is either an explicit operation in your algebra or is simply the special case of the (natural) join where there are no common column names. In the latter case you can just replace the join*[]* with join[].

-- 
  Jan Hidders
Received on Mon Aug 27 2001 - 23:18:04 CEST

Original text of this message