Dealing with databases, how do i find MAX using relational algebra?
Presuming you've got a relation, A, having a single attribute, 'a' (reducing a far more complex regards to this can be a simple task in relational algebra, I am sure you have this far), now you need to discover the maximum value inside a.
One method to get it done is to locate the mix product of the with itself, make sure to relabel 'a' so that your new relation has characteristics with distinct names. for instance:
(relabel 'a' as 'a1') X (relabel 'a' as 'a2')
now choose 'a1' < 'a2', the resulting relation may have all values except the utmost. To find the max simply discover the distinction between your original relation:
A - (select 'a1' < 'a2') ((rename 'a' as 'a1')(A) X (rename 'a' as 'a2')(A))
I am sorry for that notation, I'm not sure ways to get the relational algebra symbols with subscripts etc to exhibit within this text-box.
I have forgotten the majority of the relational algebra syntax now. A question simply using
RENAME could be
SELECT v1.number FROM values v1 MINUS SELECT v1.number FROM values v1 JOIN values v2 ON v2.number > v1.number
Hopefully you are able to translate!