Relational Model Practice Problems

Consider this schema from the textbook for a university database:

university-schema.png

Consider this schema for an employee database:

employee-schema.png

Give a relational algebra expression for each of the following queries:5

  1. Find the name of each employee who lives in city "Miami".
  2. Find the name of each employee whose salary is greater than $100000.
  3. Find the name of each employee who lives in "Miami" and whose salary is greater than $100000.

Footnotes:

1

A relation. The name of the relation is in blue, with the attributes of the relation listed underneath.

2

They form the primary key for that relation. A primary key uniquely identifies each tuple in the relation. Every tuple must have a value for these attributes (i.e., they cannot be NULL)

3

These are foreign key relationships, where an attribute in one relation refers to the primary key in another relation.

4

A course could have multiple prerequisites, and so might need to appear in multiple tuples. Thus, both attributes are required to uniquely identify a tuple.

5
  1. \(\Pi_{person\_name}(\sigma_{city = "Miami"}(employee))\)
  2. \(\Pi_{person\_name}(\sigma_{salary > 100000}(works))\)
  3. \(\Pi_{person\_name}(\sigma_{city = "Miami" \;\land\; salary > 100000}(employee \bowtie_{person\_name} works))\)