Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Database employee (employee_name, street, city) works (employee_name, company_na

ID: 3793615 • Letter: D

Question

Database

employee (employee_name, street, city)
works (employee_name, company_name, salary)
company (company_name, city)
manages (employee_name, manager_name)

1. Find the number of employees of each company. Rename the second attribute in the output as number_employees. Assume that each company has at least one employee.

2. For companies that have at least three employees, find company name and number of empolyees. Rename the second attribute in the output as number_employees. Remark: this question is similar to the previous one but the output lists only companies with at least three employees.

Explanation / Answer

1. Select count(*) from employee e , company c, works w where e.employee_name=W.employee_name and w.company_name=c. Company_name

2.select e.company_name from employee e inner join works w on w.company_name=e.company_name inner join company c where c.company=e.company_name and count( e.employee_name ) >=3