PRAGMA foreign_keys = ON;

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ("table", "index", "trigger");
PRAGMA writable_schema = 0;
VACUUM;

CREATE TABLE "battle" (
"id" INT,
"name" TEXT,
"result" TEXT,
PRIMARY KEY ("id")
);

CREATE TABLE "death" (
"caused_by_ship_id" INT,
"id" INT,
"note" TEXT,
"killed" INT,
"injured" INT,
PRIMARY KEY ("id"),
FOREIGN KEY ("caused_by_ship_id") REFERENCES "ship"("id")
);

CREATE TABLE "ship" (
"id" INT UNIQUE,
"name" TEXT,
"tonnage" TEXT,
"ship_type" TEXT,
PRIMARY KEY ("id")
);





INSERT INTO "battle" VALUES ("1", "Battle of Trafalgar", "Victory");
INSERT INTO "battle" VALUES ("2", "Battle of Jutland", "Indecisive");
INSERT INTO "battle" VALUES ("3", "Battle of Midway", "Victory");
INSERT INTO "battle" VALUES ("4", "Battle of the Atlantic", "Ongoing");
INSERT INTO "battle" VALUES ("5", "Battle of Leyte Gulf", "Victory");
INSERT INTO "ship" VALUES ("101", "HMS Victory", "t", "Ship of the line");
INSERT INTO "ship" VALUES ("102", "USS Arizona", "b", "Battleship");
INSERT INTO "ship" VALUES ("103", "Bismarck", "t", "Battleship");
INSERT INTO "ship" VALUES ("104", "Yamato", "x", "Battleship");
INSERT INTO "ship" VALUES ("105", "USS Enterprise", "m", "Aircraft carrier");
INSERT INTO "ship" VALUES ("106", "HMS Hood", "t", "Battlecruiser");
INSERT INTO "ship" VALUES ("107", "USS Missouri", "m", "Battleship");
INSERT INTO "death" VALUES ("101", "201", "Hit by cannon fire during battle", "50", "20");
INSERT INTO "death" VALUES ("103", "202", "Sunk by torpedoes", "2100", "300");
INSERT INTO "death" VALUES ("106", "203", "Exploded after magazine detonation", "1415", "300");
INSERT INTO "death" VALUES ("101", "204", "Fire outbreak in engine room", "5", "10");
INSERT INTO "death" VALUES ("102", "205", "Bombed during air raid", "1177", "350");
INSERT INTO "death" VALUES ("101", "206", "Accidental explosion during training", "0", "2");
INSERT INTO "death" VALUES ("105", "207", "Air attack damage", "20", "50");
INSERT INTO "death" VALUES ("103", "208", "Collision damage", "10", "5");
INSERT INTO "death" VALUES ("106", "209", "Hit by enemy shell", "100", "50");
INSERT INTO "death" VALUES ("101", "210", "Minor skirmish damage", "1", "0");