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,
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,
"name" TEXT,
"tonnage" TEXT,
PRIMARY KEY ("id"),
FOREIGN KEY ("lost_in_battle") REFERENCES "battle"("id")
);





INSERT INTO "battle" VALUES ("1", "Battle of Midway");
INSERT INTO "battle" VALUES ("2", "Battle of the Atlantic");
INSERT INTO "battle" VALUES ("3", "Battle of Leyte Gulf");
INSERT INTO "battle" VALUES ("4", "Battle of Jutland");
INSERT INTO "battle" VALUES ("5", "Battle of Tsushima");
INSERT INTO "ship" VALUES ("1", "101", "USS Yorktown", "20000t");
INSERT INTO "ship" VALUES ("1", "102", "IJN Akagi", "36500t");
INSERT INTO "ship" VALUES ("2", "103", "U-96", "769t");
INSERT INTO "ship" VALUES ("2", "104", "HMS Hood", "42100t");
INSERT INTO "ship" VALUES ("3", "105", "USS Enterprise", "25500t");
INSERT INTO "ship" VALUES ("3", "106", "IJN Musashi", "72800t");
INSERT INTO "ship" VALUES ("4", "107", "SMS Seydlitz", "28550t");
INSERT INTO "ship" VALUES ("4", "108", "HMS Lion", "26270t");
INSERT INTO "ship" VALUES ("5", "109", "Knyaz Suvorov", "13516t");
INSERT INTO "ship" VALUES ("5", "110", "Mikasa", "15140t");
INSERT INTO "ship" VALUES ("NULL", "111", "USS Arizona", "34000t");
INSERT INTO "ship" VALUES ("NULL", "112", "Bismarck", "41700t");
INSERT INTO "ship" VALUES ("NULL", "113", "Yamato", "72800t");
INSERT INTO "ship" VALUES ("NULL", "114", "USS Missouri", "45000t");
INSERT INTO "ship" VALUES ("NULL", "115", "HMS Victory", "2142t");
INSERT INTO "death" VALUES ("101", "1", "141", "70");
INSERT INTO "death" VALUES ("102", "2", "267", "0");
INSERT INTO "death" VALUES ("103", "3", "0", "0");
INSERT INTO "death" VALUES ("104", "4", "1415", "0");
INSERT INTO "death" VALUES ("105", "5", "0", "0");
INSERT INTO "death" VALUES ("106", "6", "1023", "0");
INSERT INTO "death" VALUES ("107", "7", "11", "27");
INSERT INTO "death" VALUES ("108", "8", "14", "40");
INSERT INTO "death" VALUES ("109", "9", "867", "0");
INSERT INTO "death" VALUES ("110", "10", "113", "243");
INSERT INTO "death" VALUES ("111", "11", "1177", "0");
INSERT INTO "death" VALUES ("112", "12", "2000", "0");
INSERT INTO "death" VALUES ("113", "13", "3050", "0");
INSERT INTO "death" VALUES ("114", "14", "0", "0");
INSERT INTO "death" VALUES ("115", "15", "57", "102");