Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This exercise concerns World War II capital ships. Ships are built in classes from the same design, and the class is usually named for the

This exercise concerns World War II capital ships. Ships are built in "classes" from the same design, and the class is usually named for the first ship of that class. The CLASSES table records the name of the class, the type (bb for battleship or bc for battlecruiser, etc.), the country that built the ship, the number of main guns, the bore (diameter of the gun barrel, in inches) of the main guns, and the displacement (weight, in tons). The SHIPS table records the name of the ship, the name of its class, and the year in which the ship was launched. The BATTLES table gives the name and date of battles involving these ships, and the OUTCOMES table gives the result (either sunk, damaged, or ok) for each ship in a battle. (Note: some of the outcomes data has been fabricated for the purposes of this assignment.)
Use the attached SQL script to create the tables in SQLite and populate them with sample data. Then write SQL queries to answer the following ten questions. Your queries should work for arbitrary data, not only the data currently found in the tables.
1: List the name, displacement, and number of guns of the ships engaged in the battle of Guadalcanal.
2: Find the classes of ships that have exactly two ships as members of that class.
3: Find the names of the countries that had both battleships and battlecruisers.
4: Find those ships that were damaged in one battle, but later fought in another.
5: Find those battles that featured at least four ships from a single country.
6: List each country and the ship name(s) with the greatest number of guns for that country.
7: Find the battles in which Kongo-class ships participated.
8: For each country, find the average number of guns found on battleship classes.
9: For each class, find the year in which the first ship of that class launched.
10: For each class, count the number of ships of that class that were sunk in battle.
create table classes (
class varchar(20),
type char (2),
country varchar (20),
numGuns int,
bore int,
displacement int,
primary key (class)
;
create table ships (
name varchar(20),
class varchar(20),
launched int,
primary key (name),
foreign key (class) references classes(class)
;
create table battles (
name varchar(20),
date date,
primary key (name)
;
create table outcomes (
ship varchar(20),
battle varchar(20),
result varchar(10),
primary key (ship, battle),
foreign key (ship) references ships(name),
foreign key (battle) references battles(name)
;
insert into classes values ('Bismarck','bb', 'Germany', 8,15,42000);
insert into classes values ('Iowa','bb', 'USA', 9,16,46000);
insert into classes values ('Kongo','bc', 'Japan', 8,14,32000);
insert into classes values ('North Carolina', 'bb', 'USA', 9,16,37000);
insert into classes values ('Renown','bc','Gt. Britain', 6,15,32000);
insert into classes values ('Revenge','bb','Gt. Britain', 8,15,29000);
insert into classes values ('Tennessee','bb', 'USA', 12,14,32000);
insert into classes values ('Yamato','bb', 'Japan', 9,18,65000);
insert into ships values ('California', 'Tennessee', 1921);
insert into ships values ('Haruna', 'Kongo', 1915);
insert into ships values ('Hiei', 'Kongo', 1914);
insert into ships values ('Iowa', 'Iowa', 1943);
insert into ships values ('Kirishima', 'Kongo', 1915);
insert into ships values ('Kongo', 'Kongo', 1913);
insert into ships values ('Missouri', 'Iowa', 1944);
insert into ships values ('Mushashi', 'Yamato', 1942);
insert into ships values ('New Jersey', 'Iowa', 1943);
insert into ships values ('North Carolina', 'North Carolina', 1941);
insert into ships values ('Ramillies', 'Revenge', 1917);
insert into ships values ('Renown', 'Renown', 1916);
insert into ships values ('Repulse', 'Renown', 1916);
insert into ships values ('Resolution', 'Revenge', 1916);
insert into ships values ('Revenge', 'Revenge', 1916);
insert into ships values ('Royal Oak', 'Revenge', 1916);
insert into ships values ('Royal Sovereign', 'Revenge', 1916);
insert into ships values ('Tennessee', 'Tennessee', 1920);
insert into ships values ('Washington', 'North Carolina', 1941);
insert into ships values ('Wisconsin', 'Iowa', 1944);
insert into ships values ('Yamato', 'Yamato', 1941);
insert into battles values ('North Atlantic', '1941-05-24');
insert into battles values ('Guadalcanal','1942-11-15');
insert into battles values ('North Cape', '1943-12-26');
insert into battles values ('Surigao Straight', '1944-10-25');
insert into outcomes values ('California', 'Surigao Straight', 'ok');
insert into outcomes values ('Haruna', 'Surigao Straight', 'sunk');
insert into outcomes values ('Iowa', 'Guadalcanal', 'ok');
insert into outcomes values ('Iowa', 'Surigao Straight', 'ok');
insert into outcomes values ('Kirishima', 'Guadalcanal', 'sunk');
insert into outcomes values ('Mushashi', 'Surigao Straight', 'sunk');
insert into outcomes values ('New Jersey', 'Guadalcanal', 'damaged');
insert into outcomes values ('New Jersey', 'Surigao Straight', 'ok');
insert into outcomes valu
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago