1
Due: Monday, February 25 (4:30pm) Deadline: Monday, March 4 (4:30pm) (90 points) Consider the same database concerning World War II capital ships as in Homework 3: CLASSES ( class, type, country, numGuns, bore, displacement ) SHIPS ( name, class, launched ) BATTLES ( battle, date ) OUTCOMES ( ship, battle, result ) Ships are built in "classes" from the same design, and the class is usually named for the first ship of the class. The relation CLASSES records the name of the class, the type (bb for battleship or bc for battle cruiser), the country that built the ship, the number of main guns, the bore (diameter of the gun barrel, in inches) of the main gun, and the displacement (weight, in tons). The relation SHIPS records the name of the ship, the name of its class, and the year in which the ship was launched. The relation BATTLES gives the name and date of battles involving these ships, and finally, the relation OUTCOMES gives the result (sunk, damaged, or ok) for each ship in each battle. Express the following queries in SQL: Find the ships that were launched before 1943 and damaged in the battle of the North Atlantic a. Find the ships with at least 7 guns that were never damaged in each battle (i.e., they were ok or sunk) b. Find class name and country for all classes with at least 7 guns c. Find all ships that have the same name as their class. d. Find the ships that were launched before 1921 and sunk in the battle of the North Atlantic. e. Find all ships mentioned in the database (ship names may occur in more than one relations) . f. Find the average number of guns of battleships classes. g. Find for each class the year in which the first ship of that class was launched. h. Find for each class with at least two ships the number of ships of that class sunk in battle. i. Execute your queries in Problem 1 on the database provided on the Oracle database and show the result. Details will be posted on the class website. 4. (30 points) Exercise 5.2(3)(6)(11) 5. (40 points) Exercise 5.3(2)(5)(9)(12) 6. (20 points) Exercise 5.4(5)(8) 7. (60 points) Exercise 5.8 2(a)(c)(e)(g)(i)(l) 8.

Homework 4fvf

Embed Size (px)

DESCRIPTION

vddddddd

Citation preview

Page 1: Homework 4fvf

Due: Monday, February 25 (4:30pm)Deadline: Monday, March 4 (4:30pm)

(90 points) Consider the same database concerning World War II capital ships as inHomework 3:

CLASSES ( class, type, country, numGuns, bore, displacement )SHIPS ( name, class, launched )BATTLES ( battle, date )OUTCOMES ( ship, battle, result )

Ships are built in "classes" from the same design, and the class is usually named for the firstship of the class.The relation CLASSES records the name of the class, the type (bb for battleship or bc for battlecruiser), the country that built the ship, the number of main guns, the bore (diameter of thegun barrel, in inches) of the main gun, and the displacement (weight, in tons).The relation SHIPS records the name of the ship, the name of its class, and the year in whichthe ship was launched.The relation BATTLES gives the name and date of battles involving these ships, and finally, therelation OUTCOMES gives the result (sunk, damaged, or ok) for each ship in each battle.

Express the following queries in SQL:

Find the ships that were launched before 1943 and damaged in the battle of the NorthAtlantic

a.

Find the ships with at least 7 guns that were never damaged in each battle (i.e., theywere ok or sunk)

b.

Find class name and country for all classes with at least 7 gunsc.Find all ships that have the same name as their class.d.Find the ships that were launched before 1921 and sunk in the battle of the NorthAtlantic.

e.

Find all ships mentioned in the database (ship names may occur in more than onerelations) .

f.

Find the average number of guns of battleships classes.g.Find for each class the year in which the first ship of that class was launched.h.Find for each class with at least two ships the number of ships of that class sunk inbattle.

i.

Execute your queries in Problem 1 on the database provided on the Oracle database andshow the result. Details will be posted on the class website.

4.

(30 points) Exercise 5.2(3)(6)(11)5.(40 points) Exercise 5.3(2)(5)(9)(12)6.(20 points) Exercise 5.4(5)(8)7.(60 points) Exercise 5.8 2(a)(c)(e)(g)(i)(l)8.