Uploaded by Muhammad Usama Saleem

Relational algebra exercise

advertisement
Q3: Evaluate the following query that finds the maximum salary of employees using the
Cartesian product only. You may assume a few tuples for its solution.
Select max (sal) from emp;
Sol:
∏sal (emp) - ∏emp.sal ( σemp.sal>e.sal (emp x pe(emp) )
Q4: Consider the following relations containing airline flight information:




Flights flno: integer, from: string, to: string, distance: integer, departs: time, arrives: time)
Aircraft (aid: integer, aname: string, cruising range: integer)
Certified (eid: integer, aid: integer)
Employees (eid: integer, ename: string, salary: integer)
1. Find the names of pilots who can operate planes with a range greater than 3,000 miles
but are not certified on any Boeing aircraft.
∏ename( Certified x Employees x (σ cruising-range>3000 and aname Not Like ‘%Boeing%’(Aircraft) )
2. Find the eids of employees who are certified for the largest number of aircraft.
We can’t represent sum function using relational Algebra. This query require to show
employees that are certified for largest number of Aircraft, which require sum
functionality.
3. Find the total amount paid to employees as salaries.
We can’t represent sum function using relational Algebra. This query require to show
the total amount paid to employees as salaries.
4. Find the eids of pilots certified for some Boeing aircraft.
∏eid( Certified x (σ aname Like ‘%Boeing%’(Aircraft) )
5. Find the names of pilots certified for some Boeing aircraft.
∏ename( Certified x (σ aname Like ‘%Boeing%’(Aircraft) )
Download