Exercise 6.5.2: Write the following database modifications, based on the databas
ID: 3715149 • Letter: E
Question
Exercise 6.5.2: Write the following database modifications, based on the database schema Classes (class, type, country, numGuns, bore, displacement) Ships(name, class, launched) Battles (name, date) Outcomes(ship, battle, result) of Exercise 2.4.3. Describe the effect of the modifications on the data of that exercise a) The two British battleships of the Nelson class - Nelson and Rodney were both launched in 1927, had nine 16-inch guns, and a displacement of 34,000 tons. Insert these facts into the database.Explanation / Answer
A)
CREATE TABLE Classes (
class CHAR(20),
type CHAR(5),
country CHAR(20),
numGuns INTEGER,
bore DECIMAL(3,1),
displacement INTEGER
)
Insert into classes (class, type, country, numGuns, bore, displacement) values ("Nelson","ship","British",9,16,34000)
Insert into Ships("Nelson","Nelson",1927)
Insert into Ships("Rodney","Nelson",1927)
2)
Insert into classes (class, type, country, numGuns, bore, displacement) values ("Vittorio","ship","Italian",9,15,41000)
Insert into classes (class, type, country, numGuns, bore, displacement) values ("Venoto","ship","Italian",9,15,41000)
Insert into classes (class, type, country, numGuns, bore, displacement) values ("Roma","ship","Italian",9,15,41000)
3)
Delete * from ships S
FROM Classes C, Ships S
WHERE C.class = S.class
AND EXISTS
(SELECT ship
FROM Outcomes O
WHERE O.result='sunk'
AND O.ship = S.name )
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.