The following are my tables,
Staff(enum,etitle,ename), pk:enum
Has(enum,anum), pk:(enum,anum), fk1:Has(enum)->Staff(enum), fk2:Has(anum)->Area(anum)
Area(anum,aname), pk:anum
Problem:
The staff (enum, ename, etitle) who specialize in every medical area.
I have tried the following,
I know that the relational algebra expression for this query would be
divide (Staff join Has) by (project area over anum)
My SQL query is the following:
select S.enum
from Staff S
where not exists
(select A.anum from Area A)
minus
(select H.anum
from Has H,Staff S1
where H.enum = S1.enum)
But no rows are being returned. I made sure that there is one staff member who specializes in every area.
What I think should be done:
The each staff member's areas must be subtracted from all the areas. If there exists a staff member with all medical areas, then the subtraction would return a null set and the not exists would be satisfied. Then we have to retrive the enum,ename,etitle for the particular staff member.
Note:
This is my homework. I'm posting this after trying very hard.