02:36

# Exercise #39 page 1

Define the ships that "survived for future battles"; being damaged in one battle, they took part in another.

Here is example of wrong understood condition:

Solution 3.4.1

Console
Execute
`SELECT DISTINCT ship FROM Outcomes osWHERE EXISTS (SELECT ship  FROM Outcomes oa WHERE oa.ship = os.ship AND  result = 'damaged' ) AND  EXISTS (SELECT SHIP FROM Outcomes ou WHERE ou.ship=os.ship GROUP BY ship  HAVING COUNT(battle)>1 );`

This solution is realized in a relational calculus style, namely, the boats which were damaged (first EXISTS) and which were participated in more then one battle (second EXISTS) are being searched in the Outcomes table.

The mistake is the condition "preserved for future sea-battle" was ignored; this phrase implies, that after the battle, where the ship was damaged, it fought in LATER battle . Thus, reception of the correct decision for this task, need s to review dates of battles, which contain in table of battles (Battles table).

 Pages 1 2 3 4
Tags
The book was updated
several days ago