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

Exercise 6.4. 7: Write the following queries, based on the database schema Class

ID: 3823522 • Letter: E

Question

Exercise 6.4. 7: Write the following queries, based on the database schema

Classes(class, type, country, numGuns, bore, displacement)

Ships(name, class, launched)

Battles(name, date)

Outcomes(ship, battle, result)

a) Find the number of battleship classes.

b) Find the average number of guns of battleship classes.

! c) Find the average number of guns of battleships. Note the difference between

(b) and (c); do we weight a class by the number of ships of that

class or not?

! d) Find for each class the year in which the first ship of that class was

launched.

! e) Find for each class the number of ships of that class sunk in battle.

Explanation / Answer

Select count (class) from Classes where type=bb Select average (numGuns) from Classes where type=bb Select average (numGuns) from Ships, Classes where Ships. Class = Classes.class and type=bb Select min(launched) from Ships group by class Select count(ship)from Outcomes, Ship Where Outcomes.ship=Ships.name and outcome=Sunk Group by class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote