You are on page 1of 2

Example1.

Consider the following relational schemas:


employee (person-name, street, city)
works (person-name, company-name, salary)
company (company-name, city)
manages (person-name, manager-name)
Give an expression in the relational algebra to express
each of the following queries:
1) Find the names of all employees who work for “First
Bank Corporation”.
2) Find the names of all employees who live in “Miami”
and whose salary is greater than $100,000.

Ans:
1. Π person-name (σ company-name =”First Bank Corporation” (works))
2. Π person-name (σ city =”Miami” ˄ salary > 100000 (employee works ))

Example2. What is the result of the following expressions?


1. Πbuilding (σ(capacity > 30 ˄ budget < 90000)(classroom department))

2. Π course_id (σ ( year = 2009 ˄ semester = ‘Fall’)(teaches))

department
dept_name building budget
claasroom teaches Biology Watson 90000
building room_number capacity ID course_id sec_id semester year Comp,sci. Taylor 100000
packard 101 500 10101 CS-315 1 Spring 2010 Elec.Eng. Taylor 85000
Painter 514 10 10101 CS-347 1 Fall 2009 Finance Painter 120000
Taylor 3128 70 12121 FIN-201 1 Spring 2010 Historypainter Painter 50000
watson 100 30 15151 MU-199 1 Spring 2010 Music Packard 80000
watson 120 50 22222 PHY-101 1 Fall 2009 Physics Watson 70000
Ans:
1. Query1
building
Taylor
packard
watson
2.
Query2
course_id
CS-101
CS-347
PHY-101

You might also like