

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Problem 2. a. Πperson- name ( σcompany- name = “First Bank Corporation” ( works)) b. Π person- name, city ( employee ⋈ ( σcompany- name = “First Bank Corporation” ( works))) c. Πperson- name, street, city ( σ( company- name = “First Bank Corporation” ∧ salary > 10000) ( works ⋈ employee)) d. Π person- name ( employee ⋈ works ⋈ company) e. Note: Small Bank Corporation will be included in each answer. Πcompany- name ( company ÷ (Πcity ( σcompany- name=“Small Bank Corporation” ( company))))
a. t 1 ←Π isbn( σpublisher=“ McGraw−Hill ” ( books)) Π name(( employee ⋈ loan) ⋈ t 1 )) b. t 1 ←Π isbn( σpublisher=“ McGraw−Hill ” ( books)) Π name,isbn( employee ⋈ loan) ÷ t 1 c. t 1 ←employee ⋈ loan ⋈ ( σpublisher=“ McGraw−Hill ” ( books)) Π name ( σcount( isbn) > 5 (( empno Gcount−distinct( isbn)( t 1 )))) d. t 1 ←employee ⋈ loan ⋈ books Π publisher,name ( σcount( isbn) > 5 (( publisher,empno Gcount−distinct( isbn)( t 1 )))
a. select employee_name from works where company_name = ‘First Bank’;
b. select employee.employee_name, employee.street, employee.city from employee, works, company where employee.employee_name = works.employee_name AND employee.city = company.city AND company.company_name = works.company_name ;
c. select T.employee_name, T.street_name, T.city from employee T, employee S, manages where T.employee_name = manages.employee_name AND S.employee_name = manages.manager_name AND T.street_name = S.street_name AND T.city = S.city ;
select employee_name from works T where salary > ( select avg ( salary ) from works S where T.company name = S.company name );
from works group by company name having sum ( salary ) <= all ( select sum ( salary ) from works
a. select distinct A from r; b. select * from r where B = 17 c. select distinct * from r , s d. select distinct A, F from r , s where C = D
a. ( select * from r 1) union ( select * from r 2)
b. We can also write this using the intersect operation. select * from r 1 where (A, B, C) in ( select * from r 2)
c. select ∗ from r 1 where (A, B, C) not in ( select ∗ from r 2) This can also be solved using the except clause.
d. select r 1 .A , r 2 .B , r 2 .C from r 1, r 2 where r 1 .B = r 2 .B
a. select name from employee e , books b , loan l where e.empno = l.empno and l.isbn = b.isbn and b.publisher = ’McGrawHill’
b. select distinct e.name from employee e where not exists (( select isbn from books where publisher = ’McGrawHill’) except ( select isbn from loan l where l.empno = e.empno ))
c. select publisher , name from ( select publisher , name , count isbn from employee e , books b , loan l where e.empno = l.empno and l.isbn = b.isbn group by publisher , name ) as emppub(publisher, name, count books) where count books > 5