0% found this document useful (0 votes)
13 views

Homework 2

This document provides the relational algebra problems and notation for Homework 2. It includes two questions - the first asks to write queries over relations about World War 2 ships and requires tabular results for parts a-c, the second asks to determine the maximum number of tuples for relational expressions. Ship designations that could be in the Classes relation are defined at the end.

Uploaded by

aaa zzz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Homework 2

This document provides the relational algebra problems and notation for Homework 2. It includes two questions - the first asks to write queries over relations about World War 2 ships and requires tabular results for parts a-c, the second asks to determine the maximum number of tuples for relational expressions. Ship designations that could be in the Classes relation are defined at the end.

Uploaded by

aaa zzz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COSC 4820, Spring 2023

Homework 2, Relational Algebra

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.

Question 1: [45 points]


More about World War II ships. There is some data for these relations on pages 56 and
57 of the text. Note: there are some “dangling tuples” in this data, e.g., ships mentioned
in Outcomes that are not mentioned in Ships.
Write expressions of relational algebra to answer the following queries. Your queries
should run on these relations REGARDLESS of the data in them. For the first 3 (a, b,
and c) ALSO give the results of the queries in a tabular format.
Classes(class, type, country, numGuns, bore, displacement)
Ships(name, class, launched)
Battles(name, date)
Outcomes(ship, battle, result

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.

Question 2: [20 points]


Suppose relations R and S have n tuples and m tuples respectively. Give the maximum
numbers of tuples that the results of the following expressions can have.
(a) [5 points] R ∪ S.
(b) [5 points] R ./ S.
(c) [5 points] σC (R) × S, for some condition C.
(d) [5 points] πL (R) − S, from some list of attributes L.

******************************************************************************
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

You might also like