Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relational Algebra - Select & Project

Similar presentations


Presentation on theme: "Relational Algebra - Select & Project"— Presentation transcript:

1 Relational Algebra - Select & Project
Given the following tables: employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Select Find all people who work in “First Bank Corporation” company_name=“First Bank Corporation”(works) Project Find all company names company_name(company)

2 Relational Algebra - Union & Intersection
Given the following tables: employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Union Find every person who is either an employee or a manager (there is automatic duplicate elimination in all algebra operations) person_name(employee)∪manager_name(manages) Intersection Find all persons that are both employee and manager. person_name(employee)∩manager_name(manages)

3 Relational Algebra – Set Difference
Given the following tables: employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Set Difference Find all persons that are employee but not manager. person_name(employee) – manager_name(manages)

4 Relational Algebra – Cartesian Product & Natural Join
Given the following tables: employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Cartesian Product Produces all possible combinations of records from employee and works. employee  works Natural Join Show the employee names, city, and the salary for their jobs (for employees who work in some company). person_name, city, salary(employee works)

5 Relational Algebra – Division
Given the following tables: employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Division Find all persons that work in all companies. (person_name, company_name(works))  (company_name(company))

6 Exercises Given the following tables:
employee (person_name, gender, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Find the names of all the “female” employees who work in the company “XX”.

7 Relational Algebra & Tuple Relational Calculus
Given the following tables: employee (person_name, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Find the name of all employees who earn more than $10,000 person_name (salary > “10000” (works))

8 Relational Algebra & Tuple Relational Calculus
Given the following tables: employee (person_name, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Find the cities of the companies that “Jay” works for company.city (company (person_name = “Jay” (works)))

9 Exercises Given the following tables:
employee (person_name, street, city) works (person_name, company_name, salary) company (company_name, city) manages (company_name, manager_name) Find the names and cities of employees who work for “First Bank Corporation” Emphasize that the scope of s is indicated by the following bracket and should be carefully specified.


Download ppt "Relational Algebra - Select & Project"

Similar presentations


Ads by Google