Query Processing Exercise
Query Processing Exercise
Database System
February, 16th 2017
Relational Algebra
employee (person_name, street, city )
Company works (person_name, company_name, salary)
for Execise
Note: Use this schema for exercise part #1-3
Consider the Company Relational Database, where the
primary keys are underlined. Give an expression in the
relational algebra to express each of the following
queries:
a. Find the names of all employees who live in the
same city and on the same street as do their
Part #1 managers.
b. Find the names of all employees in this database
who do not work for Central Bank Corporation.
c. Find the names of all employees who earn more
than every employee of National Bank
Corporation.
Consider the Company Relational Database where the
primary keys are underlined. Give an expression in
relational algebra for each of the following queries:
a. Find all employees who work directly for Adam
b. Find all cities of residence of all employees who
Part #2 work directly for Adam
c. Find the name of the manager of the manager of
Adam
d. Find those employees who earn more than all
employees living in the city Sydney
a. Find the names of all employees who work for
Central Bank Corporation.
b. Find the names and cities of residence of all
employees who work for Central Bank
Corporation.
c. Find the names, street addresses, and cities of
residence of all employees who work for Central
Part #3 Bank Corporation and earn more than $15,000.
d. Find the names of all employees in this database
who live in the same city as the company for which
they work.
e. Assume the companies maybe located in several
cities. Find all companies located in every city in
which National Bank Corporation is located.
Query Evaluation
Plan
Choose 2 relational algebra (RA) expressions (from the
answer of previous exercises).
Part #4 For each RA, create a Query Evaluation Plan (QEP) by
selecting the appropriate algorithm.
Let relations r1(A, B,C) and r2(C, D, E) have the
following properties:
r1 has 100,000 tuples,r2 has 135,000 tuples, 25 tuples
of r1 t on one block, and 30 tuples of r2 t on one
block.
Part #5 Estimate the number of block transfers and seeks
required, using each of the following join strategies for
r1 r2:
a. Nested-loop join.
b. Block nested-loop join.