Question: 2 . Consider the following relational schema. Emp ( eid: integer, ename: string, age: integer, salary: real ) Works ( eid: integer, did: integer, pct

2. Consider the following relational schema.
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pct_time: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
Write the following queries in relational algebra.
a. Print the names and ages of each employee who works in both the Hardware department and the Software department. (5 points)
b. Print the name of each employee whose salary exceeds the budget of all the departments that he or she works in. To illustrate, if the employee works in 3 departments, whose budgets are 1000,2000 and 3000 respectively, then the maximum budget of all the departments that he/she works in is 3000.(5 points)
c. Find the ename, age of managers who manage only departments with budgets greater than \(\$ 1\) million. (5 points)
d. Find the enames of managers who manage the departments with the greatest budgets. To illustrate, suppose there are three departments like this: department 1 with a budget of \(\$ 1\) million, department 2 with a budget of \(\$ 2\) million, department 3 with a budget of \(\$ 2\) million. Then departments 2 and 3 have the greatest budgets. (9 points)
Part II. SQL Queries. (30 points)
- Copy all SQL queries into one sql file called part2.sql. For each query, please provide the comment as "part2a" for the first query.
- All screenshots should be submitted together as a single pdf file called part2.pdf.
- Upload your submissions as a single archive file called part2.zip.
Consider the relational schema for company in Part I.2, write SQL queries for each request in Part I. 2 and one extra request in the following. Your queries should be executable in SQLite.
In this part, you also need to use the "A2.db"(please download "A2.db" from course files) database in DB Browser for SQLite to give a screenshot for each query's result.
a.6 points
b.5 points
c.5 points
d.6 points
e. For each department with more than 20 full-time-equivalent employees (i.e., the total pct_time of the part-time and full-time employees add up to at least 2000 hrs, assuming that the pct_time of a full-time employee is 100 hrs ), print the did together with the number of employees that work in that department. (8 points)
2 . Consider the following relational schema. Emp

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!