Consider the following relational database schema:
lives (name, street, city)
works (name, company, salary)
located (company, city)
manages (name, manager-name)
You may make the following assumptions for this problem:
- (A1)
- The first attribute is a key for each relation (i.e.,
lives.name, works.name, located.company, and
manages.name are keys).
- (A2)
- Every person in the works relation also appears in
the lives relation, but not necessarily vice-versa (i.e., no one
works without living, but people may live without working).
Specify a relational algebra expression for each of the following
queries:
- (a)
- Find the names of all people who work for IBM.
- (b)
- Find the names and cities of all people who work for IBM.
- (c)
- Find the names, streets, and cities of all people who work for
IBM and earn more than $30,000.
- (d)
- Find the names of all people who live in the same city as the
company they work for.
- (e)
- Find the names of all people who live in the same city and
on the same street as their manager.
- (f)
- Find the names of all people who are their own second-level
manager--that is, find all people P such that P's manager's
manager is P.
- (g)
- Find the names of all people who do not work for IBM.
- (h)
- Find the names of all people who earn a salary that is higher
than the salary earned by any person who works for IBM.