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





INSERT INTO "battle" VALUES ("1", "1805-10-21");
INSERT INTO "battle" VALUES ("2", "1812-09-19");
INSERT INTO "battle" VALUES ("3", "1862-03-08");
INSERT INTO "battle" VALUES ("4", "1942-06-04");
INSERT INTO "battle" VALUES ("5", "1944-10-23");
INSERT INTO "ship" VALUES ("1", "101", "HMS Victory");
INSERT INTO "ship" VALUES ("2", "102", "USS Constitution");
INSERT INTO "ship" VALUES ("3", "103", "CSS Virginia");
INSERT INTO "ship" VALUES ("3", "104", "USS Monitor");
INSERT INTO "ship" VALUES ("4", "105", "USS Enterprise");
INSERT INTO "ship" VALUES ("4", "106", "IJN Akagi");
INSERT INTO "ship" VALUES ("5", "107", "USS Indianapolis");
INSERT INTO "ship" VALUES ("5", "108", "IJN Yamato");
INSERT INTO "ship" VALUES ("5", "109", "HMS Hood");
INSERT INTO "death" VALUES ("101", "201", "50", "120");
INSERT INTO "death" VALUES ("101", "202", "30", "80");
INSERT INTO "death" VALUES ("102", "203", "20", "40");
INSERT INTO "death" VALUES ("103", "204", "60", "150");
INSERT INTO "death" VALUES ("104", "205", "10", "25");
INSERT INTO "death" VALUES ("104", "206", "5", "15");
INSERT INTO "death" VALUES ("105", "207", "100", "200");
INSERT INTO "death" VALUES ("106", "208", "90", "180");
INSERT INTO "death" VALUES ("106", "209", "40", "90");
INSERT INTO "death" VALUES ("107", "210", "70", "160");
INSERT INTO "death" VALUES ("108", "211", "80", "170");
INSERT INTO "death" VALUES ("109", "212", "110", "220");
INSERT INTO "death" VALUES ("109", "213", "60", "130");