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

EDIT QUESTION employee ( employee_name , street , city ) works ( employee_name ,

ID: 3794043 • Letter: E

Question

EDIT QUESTION

employee (employee_name, street, city)

works (employee_name, company name, salary)

company (company_name, city)

manages (employee_name, manager_name)

Consider the employee database of Figure 3.20, where the primary keys are underlined. Give an expression in SQL for each of the following queries.

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.

##An example would be like this

Find the names of all employees who work for “First Bank Corpora-

tion”.

answer:

            select employee_name

                        from works

                        where company_name = ‘First Bank Corporation’

Explanation / Answer

select c.company_name,count(*) as number_employees
from employee e, works w, company c
where c.company_name = w.employee_name and w.employee_name = e.employee_name
group by c.company_name having count(*) > 2