Question: did I do this correctly relational algebraic expressions for the following queries and how would their query trees look like. Consider the following relational schema

did I do this correctly relational algebraic expressions for the following queries and how would their query trees look like.
Consider the following relational schema and briefly answer the questions that follow. Make any assumptions ad state them as part of your answer.
Emp (eid: integer, ename: string, age: integer, salary: real, bonus:real)
Works (eid: integer, did: integer, pct_time: integer)
Dept (did: integer, dname: string, budget: real, managerid: integer)
1. Write relational algebraic expressions for the following queries and draw their query trees.
a) Retrieve the names of department where John Smith works.
Emp_JS < ename=JohnSmith(Emp)
Dept_JS < did (Works eid Emp_JS)
Deptnames_result < dname(Dept did Dept_JS)
b) List all employees who work for a manager younger than themselves.
ManagerInfo < Emp AS E1 managerid Dept
Manager_EmpInfo < ManagerInfo eid = Works.eid Emp AS E2
Younger_Mangers < ename(E2.age > E1.age(Manager_EmpInfo))
c) List all employees who do not work in any department managed by Jane Smith.
Emp_JaneS < ename = 'Jane Smith'(Emp)
Dept_JaneS = did (Dept managerid Emp_JaneS)
Emp_JaneSDept = eid(Works did Dept_JaneS)
ExcludedEmployees = eid(Emp)- Emp_JaneSDept
d) List all employees who work in every department managed by Jane Smith.
Emp_JaneS < ename =Jane Smith'(Emp)
Dept_JaneS < did(Dept managerid Emp_JaneS)
Emp_JaneSDepts = eid(Works did Dept_JaneS)
Employees_AllDepts = eid(Emp) did(Dept_JaneS)
e) List all departments were everyone who works is above 50 years old.
DeptEmp < Works eid Emp
DeptOlderEmp < did(age >50(DeptEmp))
f) Find managers who manage more than one department.
DeptManagers = managerid, count(did)(Dept)
MultiDeptManagers = count(did)>1(DeptManagers)
g) Find a manager who works more than any of his/her employees in any department.
ManagerDetails = Dept managerid Emp AS Manager
EmployeeDetails = Works eid Emp AS Employee
ManagersWithHigherWork = managerid(Manager.salary > Employee.salary(ManagerDetails EmployeeDetails))
h) Find total hours worked by all employees in department number 5.
Dept5Emp = did=5(Works)
TotalHoursDept5= SUM(pct_time)(Dept5Emp)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!