Question

24 Chapter 1: Databasics departments code projects deptcodeTK /name description startdate enddate managerid F subdeptof K workson projectidTE |revenue employeeidE assignedtime employees employeed firstname astname deptcode x Figure 1.5: Schema for the Emplovees Database

10. For each employee in the department with code ACCNT, find the employee ID and number of assigned hours that the employee is currently working on projects for other departments. Only report an employee if she has some current project to which she is assigned more than 50% of the time and the project is for another department. Report the results in ascending order by hours.

11. Find all departments where all of their employees are assigned to all of their projects.

12. Use correlated subqueries in the SELECT and WHERE clauses, derived tables, and subqueries in the HAVING clause to answer these queries. If they cannot be answered using that technique, explain why.

(a) Find the names of all people who work in the Information Technology department.

(b) Find the names of all people who work in the Information Technology department and who spend more than 20% of their time on the health project.

(c) Find the names of all people who make more than the average salary of the people in the Accounting department.

(d) Find the names of all projects that require more than 50% of an employee’s time.

(e) Find the total percentage time assigned to employee Bob Smith.

(f) Find all departments not assigned a project

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

A)

SELECT firstname FROM employees. workson, projects, department WHERE (employees.employeeid= workson.employeeid) AND (workson.projectid= projects.projectid) AND (projects.deptcode= department.code) AND assingedtime='20' AND projectid= 'ADT4MFIA'

B)

SELECT firstname FROM employees INNER JOIN workson ON (employees.employeeid= workson.employeeid) INNER JOIN projects ON (projects.deptcode= department.code) INNER JOIN department ON (workson.projectid= projects.projectid) WHERE assingedtime='20' AND projectid= 'ADT4MFIA'

C)

SELECT firstname FROM employees FULL OUTER JOIN workson ON (employees.employeeid= workson.employeeid) FULL OUTER JOIN projects ON (projects.deptcode= department.code) FULL OUTER JOIN department ON (workson.projectid= projects.projectid) WHERE assingedtime='20' AND projectid= 'ADT4MFIA'

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Add a comment
Know the answer?
Add Answer to:
10. For each employee in the department with code ACCNT, find the employee ID and number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Employee        (empID, fName, lName, address, DOB, sex, position, deptNo)             Department     (deptNo, deptName, mgrEmpID)   

    Employee        (empID, fName, lName, address, DOB, sex, position, deptNo)             Department     (deptNo, deptName, mgrEmpID)             Project            (projNo, projName, deptNo)             WorksOn         (empID, projNo, hoursWorked)             where Employee        contains employee details and empID is the key.                         Department     contains department details and deptNo is the key. mgrEmpID identifies the employee who is the manager of the department. There is only one manager for each department.                         Project            contains details of the projects in each department and the...

  • SQL Queries 1) Use the following relations to answer the problems below. Person(SSN, Age, Name) P...

    SQL Queries 1) Use the following relations to answer the problems below. Person(SSN, Age, Name) Professor(SSN, Rank, Specialty) GraduateStudent(SSN, DegreeProgram, AdvisorSSN, DepartmentNumber) Project Number, StartDate, EndDate, Budget, SponsorOrganizationName) DepartmentNumber, Name, Abbreviation, MainOffice, ChairmanSSN) WorksFor(ProfessorSSN, Department Number, TimePercentage) WorksOn(GraduateStudentSSN, ProjectNumber, SupervisingProfessorSSN) Retrieve the Name and Specialty of all Professors who do not supervise work projects. This solution must meet the following conditions: D a. Uses at most one inner joirn b. Uses at most one outer join cNo subqueries al d....

  • Given the following Schema : Employee (empNo, fName, lName, address, DOB, sex, position, deptNo) Department (deptNo,...

    Given the following Schema : Employee (empNo, fName, lName, address, DOB, sex, position, deptNo) Department (deptNo, deptName, mgrEmpNo) Project (projNo, projName, deptNo) WorksOn (empNo, projNo, dateWorked, hoursWorked) Where: Employee contains employee details and empNo is the key. Department contains department details and deptNo is the key. mgrEmpNo identifies the employee who is the manager of the department. There is only one manager for each department. Project contains details of the projects in each department and the key is projNo (no...

  • Write SQL Queries for the following Select the employee name and no of departments each employee...

    Write SQL Queries for the following Select the employee name and no of departments each employee works for Select the employee names with salary greater than average salary of all employees Select the department names with no manager assigned yet. Select the employee names who work for more than 1 department. Select the employee names and their manager names (keep in mind, one employee works for multiple departments so they will have multiple managers). Select the name and salary of...

  • ) Identify the ERD components from the given scenario. A company has several departments. Each department...

    ) Identify the ERD components from the given scenario. A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one, but possibly more departments. At least one employee is assigned to a project, but an employee may be on vacation and not assigned to any projects. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number...

  • Consider the following relational schema. An employee can work in more than one department; the pct...

    Consider the following relational schema. An employee can work in more than one department; the pct time field of the Works relation shows the percentage of time that a given employee works in a given department. Emp(eid: integer, ename: string, phone: integer, salary: real) Works(eid: integer, did: integer, pct_time: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) Write the following SQL queries. d) Find the enames of managers who manage the departments with the largest budgets. e) Find the...

  • Consider the following relational schema. An employee can work in more than one department; the p...

    Consider the following relational schema. An employee can work in more than one department; the pct_time field of the Works relation shows the percentage of time that a given employee works in a given department. Emp(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, pct_time: integer) Dept(did: integer, budget: real, managerid: integer) In the above, please note that there is an attribute pcttime (of Integer type) in the Works table, as the schema shows. A tuple/row <1,...

  • Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project...

    Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project name. If the employee never worked on a project, show the names only the name, not the project name. (7pts) Retrieve the names of employees who have worked on the same project at a different location. (7pts) Retrieve the names of employees who have worked on more than two different projects. (7pts) Retrieve the names of employees who manage more than two employees. CREATE...

  • Based on the schemas given below, give the appropriate “SQL” and “Relational algebra” statements for the...

    Based on the schemas given below, give the appropriate “SQL” and “Relational algebra” statements for the given queries Marking scheme: 1 mark for each correct syntax for SQL and Relational Algebra Employee (fname, Iname, ssn, sex, salary, dno) Department (dname, dno, managersn, dlocation) Project (pname, pno, plocation, dno) a) Find out which department “Evelyn" is working in. b) Retrieve the names of all the projects which are located in “Isa Town". c) Count the number of employees who receive a...

  • I have already turned in my HW, I need some understanding of the below SQL queries....

    I have already turned in my HW, I need some understanding of the below SQL queries. 1. Find the number of employees in each department. 2. List the names of departments that have more than 5 employees working there. 3. Retrieve the lowest and highest salary in each department. Output the department name in alphabetical order. Consider the following relational schema. An employee can work in more than on department; also, the percentTime field of the Works relations shows the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT