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....

  • 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...

  • Projects inc. is an engineering firm with approximately 50 employees A database is required to keep...

    Projects inc. is an engineering firm with approximately 50 employees A database is required to keep track of all employees, their skills, projects assigned and departments worked in. Every employee has a unique number assigned by the firm, required to store her or his name and data of birth. If an employee is currentty married to another employee of Projects tnc. the data of the marriage and who the employee is married to must be stored. Howeer no record of...

  • Problem 1 (25 points) Consider the following database schema: Employee (fname, Iname, ssn, address, salary, mgrssn,...

    Problem 1 (25 points) Consider the following database schema: Employee (fname, Iname, ssn, address, salary, mgrssn, dnumber) Department (dname, dnumber, mgrssn, mngrstartdate) Project (pname, pnumber, plocation, dnumber) Works_On (ssn, pnumber, hours_per_week) Dependent (ssn, dependent name, bdate, relationship) The above relations store information about a company. The meaning of most of the relations and attributes is straightforward. For example, the first relation stores information about employees. The mgrssn is the SSN of the manager (supervisor) of the given employee. A manager...

  • 2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department,...

    2) Consider the database schema on the relations (where key attributes have been underlined): PROJECTS(Number, Department, ProjectName) EMPLOYEES(Number, Surname, FirstName, Department) ALLOCATIONSEmplovee, Project, Function, Date) NOTE: relation ALLOCATIONS stores the registration number (attribute Employee) of employees that are assigned to a given project (attribute Project is the number of the project, not the name of the project), the function the employee has in that project (i.e., technician, manager, etc.) and the date when the employee has been assigned to that...

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
ADVERTISEMENT