Suppose I have a table of students, containing their ID and their grade:
-----------------
| id | grade |
-----------------
| 1 | 83 |
| 2 | 94 |
| 3 | 92 |
| 4 | 78 |
How do I write a Tuple Relational Calculus formula that refers to the student with the highest grade?
My attempt:
Thinking in terms of SQL, I would write a query that does a cartesian product of the table with itself, take every grade that is less than some other grade, and then subtract from the original table. However, in Tuple Relational Calculus, it's not possible to build sub-tables in sub-queries, which is why I'm stuck.
However, I've attempted something in this direction:
{ <id> | Ǝ grade1 ∈ students (id, grade) ⋀ Ǝ grade2 ∈ students (id, grade2) ⋀ grade1 > grade2}
I believe this would get me the lower grades, but how do I subtract this all from the original table of students? I'm not allowed to insert this statement into another TRC query. Thanks in advance for your help!