I have to write a relational algebra expression for a query in order to build and optimize a query tree. I have trouble understanding how to write an expression for a query involving joining of several relations.
Relations are,
Supplier(snum, name, address, bdate, sex, pnum)
Plant(pnum, mgrnum, location)
Item(item#, location, pnum)
Sells(snum, item#,qty)
Mgrnum in plant is the snum of manager in supplier table (foreign key).
The query is,
for every item located in 'Denver', retrieve the item number, the controlling plant number, and the plant manager's name, address and the date of birth.
I like to write this first using Cartesian product than using joins so i can draw the initial query tree.
This is an attempt by a friend:
PROJECT item#, pnum, mgrnum, address, bdate( (SELECT location='Denver' (Plant) x Item) JOIN mgrnum=snum (Supplier))
I'm trying to understand how to arrive at this answer. Thank you.