Answered step by step
Verified Expert Solution
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.
: List the name, displacement, and number of guns of the ships engaged in the battle of Guadalcanal.
: Find the classes of ships that have exactly two ships as members of that class.
: Find the names of the countries that had both battleships and battlecruisers.
: Find those ships that were damaged in one battle, but later fought in another.
: Find those battles that featured at least four ships from a single country.
: List each country and the ship names with the greatest number of guns for that country.
: Find the battles in which Kongoclass ships participated.
: For each country, find the average number of guns found on battleship classes.
: For each class, find the year in which the first ship of that class launched.
: For each class, count the number of ships of that class that were sunk in battle.
create table classes
class varchar
type char
country varchar
numGuns int,
bore int,
displacement int,
primary key class
;
create table ships
name varchar
class varchar
launched int,
primary key name
foreign key class references classesclass
;
create table battles
name varchar
date date,
primary key name
;
create table outcomes
ship varchar
battle varchar
result varchar
primary key ship battle
foreign key ship references shipsname
foreign key battle references battlesname
;
insert into classes values Bismarckbb 'Germany', ;
insert into classes values Iowabb 'USA', ;
insert into classes values Kongobc 'Japan', ;
insert into classes values North Carolina', bb 'USA', ;
insert into classes values RenownbcGt Britain', ;
insert into classes values RevengebbGt Britain', ;
insert into classes values Tennesseebb 'USA', ;
insert into classes values Yamatobb 'Japan', ;
insert into ships values California 'Tennessee', ;
insert into ships values Haruna 'Kongo', ;
insert into ships values Hiei 'Kongo', ;
insert into ships values Iowa 'Iowa', ;
insert into ships values Kirishima 'Kongo', ;
insert into ships values Kongo 'Kongo', ;
insert into ships values Missouri 'Iowa', ;
insert into ships values Mushashi 'Yamato', ;
insert into ships values New Jersey', 'Iowa', ;
insert into ships values North Carolina', 'North Carolina', ;
insert into ships values Ramillies 'Revenge', ;
insert into ships values Renown 'Renown', ;
insert into ships values Repulse 'Renown', ;
insert into ships values Resolution 'Revenge', ;
insert into ships values Revenge 'Revenge', ;
insert into ships values Royal Oak', 'Revenge', ;
insert into ships values Royal Sovereign', 'Revenge', ;
insert into ships values Tennessee 'Tennessee', ;
insert into ships values Washington 'North Carolina', ;
insert into ships values Wisconsin 'Iowa', ;
insert into ships values Yamato 'Yamato', ;
insert into battles values North Atlantic', ;
insert into battles values Guadalcanal;
insert into battles values North Cape', ;
insert into battles values Surigao Straight', ;
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started