Relational Algebra and Bank Corporation

Only available on StudyMode
  • Topic: Relational algebra, Relational model, Relational calculus
  • Pages : 3 (1070 words )
  • Download(s) : 101
  • Published : February 25, 2013
Open Document
Text Preview
Exercises 3
(RA - TRC -DRC )

Consider the following relational database:
employee(employee-name, street, city)
works(employee-name, company-name, salary)
company(company-name, city)
manages(employee-name, manager-name)
For each of the following queries, give an expression in relational algebra, tuple relational calculus, and domain relational calculus: a. Find the names of all employees who work for First Bank Corporation. b. Find the names and cities of residence of all employees who work for First Bank Corporation. c. Find the names, street address, and cities of residence of all employees who work for First Bank Corporation and earn more than $10,000 per annum d. Find the names of all employees in this database who live in the same city as the company for which they work. e. Find the names of all employees who live in the same city and on the same street as do their managers. f. Find the names of all employees in this database who do not work for First Bank Corporation. g. Find the names of all employees who earn more than every employee of Small Bank Corporation. h. Assume the companies may be located in several cities. Find all companies located in every city in which Small Bank Corporation is located. Answer:

NOTE:  If  t is a tuple in a relation, we use the notation t[A] to indicate the value t has for attribute A. So t[A] is the same as t.A that we used in the lectures. a. Find the names of all employees who work for First Bank Corporation: i. employee-name(company-name = "First Bank Corporation"(works)) ii. { t |  s  works (t[employee-name] = s[employee-name]  s[company-name] = "First Bank Corporation")} iii. { <p> |  c, s (<p, c, s>  works  c = "First Bank Corporation") } b. Find the names and cities of residence of all employees who work for First Bank Corporation: i. employee-name, city(employee  (company-name = "First Bank Corporation"(works))) ii. { t |  r  employee  s  works (t[employee-name] =...
tracking img