Question: Problem 4 [25 points]. There are six tables describing a company, describing employees, departments, buildings, which department(s) an employee works in (and a percentage of
![Problem 4 [25 points]. There are six tables describing a company,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/11/674010c454a38_844674010c432c38.jpg)
Problem 4 [25 points]. There are six tables describing a company, describing employees, departments, buildings, which department(s) an employee works in (and a percentage of the time for each), department managers (possibly more than one per department), and in which building an employee works (an employee may have more than one office). The primary key of each table is the attribute(s) in capitals. Other attributes are not necessarily unique. Samples of the tuples for each table are shown below: EMP - 100,000 tuples IN_DEPT - 110,000 tuples EID EName Salary Start_Date End_Date EID DID Percent_Time 001 Jane $124,000 3/1/93 null 001 101 100 002 Jim $32,000 2/29/96 null 002 102 100 003 John $99,000 12/12/98 null 003 101 60 004 Joe $55,000 2/2/92 null 003 102 40 005 Jenny $51,000 5/5/95 null 004 103 100 EID values range from 1 to 100,000 005 103 100 IN_BUILDING - 110.000 tuples EID BID BUILDING - 2,000 tuples 001 201 BID BName Address 002 201 201 ATC 1600 Ampitheatre 003 202 202 CCC 500 Crittenden 003 203 203 MFB 123 Shoreline 04 202 BID values range from 1 to 2,000 005 203 DEPT - 1,000 tuples MANAGES_DEPT - 800 tuples DID DName Annual_Budget EID DID 101 Research $1,001,000 003 101 102 Development $500,000 003 102 103 Sales $2,000,000 001 103 104 HR $250,000 DID values range from 1 to 1000 a. [2 points] Write a SQL query that retrieves the average employee salary b. [2 points] Write a SQL query that retrieves the total number of employees by department ID (DID) c. [2 points] Write a SQL query that retrieves the department ID (DID), department name (DName), and Annual_budget of the departments that do not have the lowest Annual_Budget. Note that query must feature " ANY" , and use of "limit" is not acceptable. d. [3 points] Complete the following query that retrieves the name of the department where the highest paid employee works select b.bname from building b, in_building ind, emp e where e.eid = ind.eid and ind.bid = b.bid and
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
