Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Database Schema Classes(class, type, country, numGuns, bore, displacement) Ships

ID: 669226 • Letter: D

Question

Database Schema

Classes(class, type, country, numGuns, bore, displacement)
Ships(name, class, launched)
Battles(name, date)
Outcomes(ship, battle, result)

Based on Exercise 6.2.3 (page 267-268). 1 pt. per query. 1. Find the ships lighter than 45,000 tone. 2. List the name, displacement, and number of guns of the ships ehgaged in the battle of Denmark Strait 3. List all the ships contained in the database, across all the tables. 1. Find those countries that have only battleships and no battlecruisers 5. Find those ships that fought in at least two battles, without ever being sunk. 6. Find those battles with at lest two ships of the same country

Explanation / Answer

Hi,

You want answer per query wise.(ok)

I give solution for your question. In case further queries you may ask post your questions again and i answer it.

Step 1: qns: ships lighter than 45,000 tone.

Solution:

SELECT class FROM classes WHERE displacement='displacement' <=45,000;

Explanation :

I this above query display the ship lighter than 45,000.

Step 2: 2) Qns

Ans:

SELECT ships.name,classes.displacement,classes.numGuns, FROM ships,classes WHERE ship=ANY(SELECT name,displacement,numguns FROM outcomes WHERE battle='Denmark Strait');

Step 3:

Solution:

SELECT classes.class,ships.name,outcomes.ship FROM classes,ships,outcomes;

Step 4: solution: (4,5,6) is similar

4 ) SELECT country FROM classes WHERE country = ANY (SELECT battle FROM outcomes WHERE battle='battleship');

5)SELECT class FROM ships WHERE EXISTS (SELECT * FROM Outcomes WHERE Ships.name = Outcomes.ship And result = 'ok');

6)SELECT name FROM battles WHERE EXISTS(SELECT * FROM outcomes ships.name='Denmark strait');

I solve it based on my subject, further query ask me.

Thanks for asking queries.(ALL the best)