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 Midway", "Allied Victory");
INSERT INTO "battle" VALUES ("2", "Battle of Trafalgar", "British Victory");
INSERT INTO "battle" VALUES ("3", "Battle of Jutland", "Indecisive");
INSERT INTO "battle" VALUES ("4", "Battle of Leyte Gulf", "Allied Victory");
INSERT INTO "battle" VALUES ("5", "Battle of the Coral Sea", "Allied Victory");
INSERT INTO "battle" VALUES ("6", "Battle of Tsushima", "Japanese Victory");
INSERT INTO "ship" VALUES ("1", "1", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("2", "1", "Destroyer");
INSERT INTO "ship" VALUES ("3", "2", "Ship of the Line");
INSERT INTO "ship" VALUES ("4", "3", "Battlecruiser");
INSERT INTO "ship" VALUES ("5", "3", "Dreadnought");
INSERT INTO "ship" VALUES ("6", "4", "Battleship");
INSERT INTO "ship" VALUES ("7", "4", "Cruiser");
INSERT INTO "ship" VALUES ("8", "5", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("9", "6", "Battleship");
INSERT INTO "ship" VALUES ("10", "6", "Cruiser");
INSERT INTO "death" VALUES ("1", "1", "15", "5");
INSERT INTO "death" VALUES ("2", "2", "3", "2");
INSERT INTO "death" VALUES ("3", "3", "8", "10");
INSERT INTO "death" VALUES ("4", "4", "12", "7");
INSERT INTO "death" VALUES ("5", "5", "5", "3");
INSERT INTO "death" VALUES ("6", "6", "20", "15");
INSERT INTO "death" VALUES ("7", "7", "2", "1");
INSERT INTO "death" VALUES ("8", "8", "9", "4");
INSERT INTO "death" VALUES ("9", "9", "11", "6");
INSERT INTO "death" VALUES ("10", "10", "1", "0");