A tuple relational calculus expression should be written with the usual language of first order logic.
In this case, for instance, you could write:
{ [e.Name, d.Name] | Ǝ e ∈ Employee, Ǝ d ∈ Department . e.Dept_no = d.No }
(a part from minor variations on the notation used, like “:” instead of “.”).
The idea is that you obtain the result of the query (a well formed formula of a first order logic), by finding the elements of the relations that, substituted to the free variables of the formula, make the formula true.
In this case, we have two variables, d
and e
, that range on Departments
and Employees
respectively, a condition that must be true (e.Dept_no = d.No
), and from every pair of tuples of the relations that satisfy this condition, you add to the resulting set a tuple formed by the Name
of e
and the Name
of d
(in other words you perform a simple join).
Note that the structure of the expression can be easily mapped to the SQL query (and actually this language is the origin of the SQL language, together with other additions). This can be a suggestion on how to write other queries similar to this one.