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 UNIQUE,
"name" TEXT,
"result" TEXT,
PRIMARY KEY ("id")
);

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

CREATE TABLE "ship" (
"lost_in_battle" INT,
"id" INT UNIQUE,
"ship_type" TEXT,
PRIMARY KEY ("id"),
FOREIGN KEY ("lost_in_battle") REFERENCES "battle"("id")
);





INSERT INTO "battle" VALUES ("1", "Battle of Trafalgar", "Victory");
INSERT INTO "battle" VALUES ("2", "Battle of Midway", "Victory");
INSERT INTO "battle" VALUES ("3", "Battle of Jutland", "Indecisive");
INSERT INTO "battle" VALUES ("4", "Battle of Leyte Gulf", "Victory");
INSERT INTO "battle" VALUES ("5", "Battle of the Coral Sea", "Draw");
INSERT INTO "battle" VALUES ("6", "Battle of Guadalcanal", "Victory");
INSERT INTO "ship" VALUES ("1", "101", "Destroyer");
INSERT INTO "ship" VALUES ("1", "102", "Battleship");
INSERT INTO "ship" VALUES ("1", "103", "Cruiser");
INSERT INTO "ship" VALUES ("2", "201", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("2", "202", "Destroyer");
INSERT INTO "ship" VALUES ("3", "301", "Battlecruiser");
INSERT INTO "ship" VALUES ("3", "302", "Destroyer");
INSERT INTO "ship" VALUES ("3", "303", "Cruiser");
INSERT INTO "ship" VALUES ("4", "401", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("4", "402", "Battleship");
INSERT INTO "ship" VALUES ("4", "403", "Destroyer");
INSERT INTO "ship" VALUES ("5", "501", "Cruiser");
INSERT INTO "ship" VALUES ("5", "502", "Destroyer");
INSERT INTO "ship" VALUES ("6", "601", "Battleship");
INSERT INTO "ship" VALUES ("6", "602", "Destroyer");
INSERT INTO "death" VALUES ("101", "1", "5", "10");
INSERT INTO "death" VALUES ("102", "2", "8", "15");
INSERT INTO "death" VALUES ("103", "3", "3", "5");
INSERT INTO "death" VALUES ("201", "4", "12", "20");
INSERT INTO "death" VALUES ("202", "5", "4", "8");
INSERT INTO "death" VALUES ("301", "6", "7", "12");
INSERT INTO "death" VALUES ("302", "7", "2", "3");
INSERT INTO "death" VALUES ("303", "8", "1", "1");
INSERT INTO "death" VALUES ("401", "9", "15", "25");
INSERT INTO "death" VALUES ("402", "10", "6", "10");
INSERT INTO "death" VALUES ("403", "11", "3", "7");
INSERT INTO "death" VALUES ("501", "12", "5", "9");
INSERT INTO "death" VALUES ("502", "13", "1", "2");
INSERT INTO "death" VALUES ("601", "14", "9", "14");
INSERT INTO "death" VALUES ("602", "15", "4", "6");
INSERT INTO "death" VALUES ("101", "16", "2", "4");
INSERT INTO "death" VALUES ("102", "17", "1", "3");
INSERT INTO "death" VALUES ("201", "18", "3", "5");
INSERT INTO "death" VALUES ("401", "19", "7", "11");
INSERT INTO "death" VALUES ("402", "20", "2", "4");