Databases (HT2012)

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

Also do the following exercises from "Database Systems: The Complete Book, 2/E":

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

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;

Also do the following exercises from "Database Systems: The Complete Book, 2/E":

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


Last Modified: 26 October 2012 by Graham Kemp