

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!


Q1: Min and Max sizes. 10 points
(a) Find the names of all employees who work for First Bank Corporation. i. Πperson_name(σcompany_name=FirstBankCorp(works)) ii. {p|∃w ∈ works(p.person_name = w.person_name∧w.company_name = FirstBankCorp)} iii. {〈person_name〉 |∃v(〈person_name,′^ FirstBankCorp′, v〉 ∈ works)} (b) Find the names and cities of residence of all employees who work for First Bank Corporation i. Πperson_name,city
employee ./ (σcompany_name=FirstBankCorp(works))
ii. {p|∃w ∈ works(∃e ∈ employee(w.company_name = FirstBankCorp∧ p.person_name = w.person_name∧e.person_name = w.person_name∧ p.city = e.city))} iii. {〈person_name, city〉 |∃v1(〈person_name, v 1 , city〉 ∈ employee) ∧∃v2(〈person_name, FirstBankCorp, v 2 〉 ∈ works)}
(c) Find the names, street address, and cities of residence of all employees who work for First Bank Corporation and earn more than $100,000 per annum. i. Πperson_name,street,city(employee ./ (σcompany_name=FirstBankCorp∧salary> 100000 (works))) ii. {p|∃w ∈ works(∃e ∈ employee(w.companyname = FirstBankCorp ∧ w.salary > 100000 ∧p.person_name = w.person_name∧e.person_name = w.person_name ∧ p.city = e.city ∧ p.street = e.street))} iii. {〈person_name, street, city〉 | 〈person_name, street, city〉 ∈ employee ∧∃y(〈person_name, FirstBankCorp, y〉 ∈ works) ∧ y > 100000)} (d) Find the names of all employees in this database who live in the same city as the company for which they work. i. Πperson_name(employee ./ works ./ company) ii. {p|∃e ∈ employee(∃c ∈ company(∃w ∈ works(w.company_name = c.company_name∧p.person_name = e.person_name∧e.person_name = w.personname ∧ e.city = c.city)))} iii. {〈person_name〉 |∃company_name, salary(〈person_name, company_name, salary〉 ∈ works(∃c, v(〈company_name, c〉 ∈ company ∧ 〈person_name, v, c〉 ∈ employee)))} (e) Find the names of all employees in this database who live in the same city as the company for which they work. i. and ii and iii Same as above... (f) Find the names of all employees who live in the same city and on the same street as do their manager. i. Πperson_name(σmanages.manager_name=employee 2 .person_name∧employee.street=employee 2 .street ∧employee.city=employee 2 .city(manages^ ./^ employee^ ./ ρ(employee^2 ,^ employee))) ii. {p|∃e ∈ employee(∃m ∈ employee(∃r ∈ manages(r.person_name = e.person_name ∧ r.manager_name = m.person_name) ∧ e.city = m.city ∧ e.street = m.street ∧ p.person_name = e.person_name))} iii. {〈p〉 |∃m(〈p, m〉 ∈ manages ∧ ∃s, c(〈p, s, c〉 ∈ employee ∧ 〈m, s, c〉 ∈ employee)} (g) Find the names of all employees in this database who do not work for First Bank Corporation. i. Πperson_name(σcompany_name,FirstBankCorp(works)) ii. {p|∃w ∈ works(w.company_name ,′^ FirstBankCorp′∧p.person_name = w.person_name)} iii. {〈person_name〉 |∃c, s(〈person_name, c, s〉 ∈ works∧¬(∃sa(〈person_name, FirstBankCorp, sa〉 ∈ works)))}
(a) employee ← Πperson_name,street,Newton(σperson_name=Jones(employee))∪(σperson_name,Jones(employee)) (b) works ← Πperson_name,company_name,salary∗ 1. 1 (σcompany_name=′^ FirstBankCorp′^ (works))∪ (σcompany_name,′^ FirstBankCorp′^ (works))