Suppose I have the following relations:
Branch (branchNo(PK), street, city, postcode)
Staff (staffNo(PK), fName, lName, sex, branchNo(FK))
Not that it matters for this question, but PK = primary key & FK = foreign key
How would I write the relational algebra for the following query:
List the names of all female staff that work in Glasgow.
My attempt:
σStaff.sex=F & Branch.city = Glasgow(πfName, lName, sex, branchNo(Staff) x πcity, branchNo(Branch))
I know that my selection (σ) statement (NOT TO BE CONFUSED WITH SELECT) is syntactically incorrect:
σStaff.sex=F & Branch.city = Glasgow
How do I write two selections on different relations? Or in other words, how do I express an SQL statement with two or more conditions in the WHERE clause in relational algebra? I have used '&' but this cannot be right? Do I have to embed one selection within the other?
NOT HOMEWORK
intersect
? – Greegree