Search code examples
aggregate-functionsrelational-algebra

compare an attribute value to the value of an aggregate function in relational algebra


How can one compare an attribute value to the value of an aggregate function in relational algebra?

Something like:

SELECT [attribute1 > COUNT(attribute2)] (relation)

My teacher is a stickler on only using methods described in class; however, if it is an established part of relational algebra I can argue him into accepting my answer as he is a mathematician first and foremost and couldn't take me stating he is restricting established parts of a system.


Solution

  • There is a number of scientific papers that extend relational algebra with aggregation operators. However, I am not convinced that your teacher would accept your solution since he/she probably mentioned a book he/she is using in the class, so any extensions going beyond the book language might not be acceptable. Just in case you are really curious, please consider reading the following papers:

    • G. Özsoyoğlu, Z. M. Özsoyoğlu, V. Matos. Extending relational algebra and relational calculus with set-valued attributes and aggregate functions, ACM Transactions on Database Systems 12(4), 1987

    • A. Klug. Equivalence of relational algebra and relational calculus
      query languages having aggregate functions, Journal of the ACM 29(3), 1982