文档介绍:CHAPTER 2
Exercises
Describe the differences in meaning between the terms relation and relation schema.
Answer: A relation schema is a type definition, and a relation is an instance
of that schema. For example, student (ss#, name)isarelationschemaand
ss# name
123-45-6789 Tom Jones
456-78-9123 Joe Brown
is a relation based on that schema.
Consider the relational database of Figure , where the primary keys are un-
derlined. Give an expression in the relational algebra to express each of the fol-
lowing queries:
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. Assume the companies may be located in several cities. Find all companies
located in every city in which Small Bank Corporation is located.
Answer:
Π (σ (works))
a. person-name company-name = “First Bank Corporation”
7
8 Chapter 2 Relational Model
employee (person-name, street, city)
works (person-name, company-name, salary)
company (company-name, city)
manages (person-name, manager-name)
Figure . Relational database for Exercises , and .