In: Computer Science
Given aircraft (ano ,amodel, mfgYr) fleet ( fno, src
,dest, ano ,pno ) pilot (pno, pname, gender)
write relational alzebra query for the following
1. find those pnames who havent taken a fleet
2. retreive the fno ,amodel that the pilot has named 'abc' flew
1. Retrieve pname of pilots,who havent taken a fleet.
STRUCTURED QUERY : | SELECT pilot.pname FROM pilot WHERE pilot.pno NOT IN (SELECT fleet.pno FROM fleet); |
RELATIONAL ALGEBRA QUERY : | pilot.pname pilot.pno =(fleet.pno(fleet)) (pilot) |
2. Retrieve fno, amodel that the pilot has named "abc" flew.
STRUCTURED QUERY : | SELECT fleet.fno FROM fleet INNER JOIN pilot ON fleet.pno=pilot.pno WHERE pilot.pname="abc" AND pilot.ano IN ( SELECT aircraft.ano,aircraft.amodel FROM aircraft INNER JOIN fleet ON aircraft.ano=fleet.ano); |
RELATIONAL ALGEBRA QUERY : |
fleet.fnopilot.pname="abc"^pilot.ano = [aircraft.ano,aircraft.amodel((aircraft)aircraft.ano=fleet.ano(fleet))] ((fleet)fleet.pno=pilot.pno(pilot)) |