Homework 2
Homework 2
This assignment briefly covers the relational algebra from Chapter 2 of the text. There are
two problems, each with multiple parts. document is a copy of the handout I gave in class.
Use the following alternative syntax when you type the algebra.
operation notation
union R UNION S
intersection R INTERSECT S
difference R DIFF S
projection PROJECT(attribute list){R}
selection SELECT(conditional ){S}
cartesian product PRODUCT{R, S}
natural join JOIN{R, S}
theta join THETA(conditional ){R, S}
renaming RENAME(new relation name)(attribute list){R}
R and S each stand for some relation. In the listing above attribute list is (a1 , a2 , . . . , an )
and conditional is one of a > b, a < b, a = b, a != b, a >= b, a <= b, or !a. Multiple
conditionals may be joined with AND, OR, and NOT in the usual manner. Parentheses
should be used in the conditional statements for grouping and disambiguation.
Note: For clarification, “capital ship” is an ambiguous term usually meaning the largest,
most powerful ship in a fleet. We will take it to mean Battleship (bb), Battlecruiser (bc),
and Aircraft Carrier (cv). There is a complete list of the ship types at the end of this
document. It contains more entries that the Classes table on page 56.
(a) [5 points] Give the class names and countries of the classes that carried guns of at
least 16-inch bore.
(b) [5 points] Find the ships launched prior to 1920.
(c) [5 points] Find the ships sunk in the battle of the Surigao Strait.
(d) [5 points] The treaty of Washington in 1921 prohibited capital ships heavier than
35,000 tons. List the ships that violated the treaty of Washington.
(e) [5 points] list the name, displacement, and number of guns of the ships engaged in
the battle of Denmark Strait.
(f) [5 points] list all the Capital ships mentioned in the database. Remember that all
these ships may NOT appear in the Ships relation.
(g) [5 points] Find the classes that had only one ship as a member of that class.
(h) [5 points] Find those countries that had both battleships and battlecruisers.
(i) [5 points] Find those ships that were damaged in one battle, but later fought in
another.
******************************************************************************
Ship designations possibly used in “Classes”.
Acronym Type
ah Hospital Ship
apa Attack Transport
av Seaplane Tender
bb Battleship
bc Battlecruiser
ca Heavy Cruiser
cl Light Cruiser
cv Aircraft Carrier
cve Escort (Aircraft) Carrier
cvl Light (Aircraft) Carrier
dd Destroyer
ddc Corvette
dde Escort Destroyer
mv Merchant Vessel
Page 2