Using primitive relational algebra operations, describe how to select a maximum value out of a relation of values.
It's not obvious, huh?
yeah i am not sure on this one i will look into it but its a difficult one
Let's consider this relation: Values [100] [ 90 ] [101] [200] [306] [ 52 ] describe a procedure using primitive relational algebra operations that will not only get the tuple containing the largest integer out of all the tuples in this relation, but would also work on any relation with the same number of attributes (i.e. 1)
so basically, I want to obtain [306]
Hmmm... Recursively applying Select > on consecutive elements all the way through the list.
Interesting problem but I have to head to work...
\[Values\] \[-\] \[\pi_{v1}(\sigma_{v1<v2}(\rho_{v1,v2}(Values\ \times\ Values)))\]
That looks about right. You're using less than, though?
So it works? yay
and if I want the minimum, I use >?
I think the other way around. select v1<v2 should give you all tuples where v1 is < v2. for max you want it the other way around.
yeah
I just got all the smaller tuples in one single-dimension list, and subtracted it from the original in order to get just the tuple with the largest value in it.
Join our real-time social learning platform and learn together with your friends!