COMP 340: Databases, Fall 2016

Homework 1: Relational Algebra

  1. Do problem 2.4.3, all parts (i.e., (a) through (i)), from the textbook. This is on page 55, though you may find it helpful to refer to the description of the database relations on page 37.)

    For each lettered sub-problem, write a relational algebra expression that answers the query, and show the results of the query using the sample data on pages 56 and 57. For part (f), you do not need to show the results because they are very long. For parts (g) and (i), note that there are no ships in the sample data that fit the query, so you do not have to show the results for these problems either.

    You may find it helpful to use the "linear notation for algebraic expressions" described in section 2.4.13 (starting on page 51). We discussed this notation in class; it lets you give temporary names to parts of a relational algebra expression, thus letting you build a big expression out of smaller pieces, which is usually easier to manage than writing one huge expression.

    Note that the problem specifies there are "dangling tuples" in the data. You are not expected to use outer joins to handle these situations; use natural or theta joins and simply disregard situations where the database doesn't have the information you need to answer the query. For instance, in the sample data, there are three ships listed in the Outcomes relation that fought in the battle of Guadalcanal, but only two of them have corresponding entries in the Ships relation. For problem (e), your query should only return tuples for which you can *find* the displacement and number of guns, which means your query will return only information on two of the ships, not all three.

  2. Do problem 2.4.5 from the textbook.