Databases (HT2014)

Tutorial 3

Returning to the same domain once again, you have identified the following relations:

Your task for this exercise is to write a number of queries, both in SQL and using relational algebra.

Relational Algebra

For each of the following, write a relational-algebraic expression that

SQL queries

For each of the following, write an SQL query that

For each of the following, write at least two significantly different SQL queries that

Translate the following SQL queries to relational-algebraic expressions:

  SELECT C.name, teacher
  FROM Courses C, Teachers T
  WHERE teacher = T.name;

  SELECT day, COUNT(DISTINCT teacher)
  FROM Courses C, Classes S
  WHERE C.name = S.course
  GROUP BY day;

Book exercises

The following exercises from "Database Systems: The Complete Book, 2/E" are relevant:

If you have the first edition of the textbook, the following exercises are similar:


Last Modified: 17 September 2014 by Graham Kemp