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





INSERT INTO "battle" VALUES ("1", "Battle of Red Cliffs", "208-11-01", "Decisive victory for allied forces");
INSERT INTO "battle" VALUES ("2", "Battle of Hastings", "1066-10-14", "Norman victory");
INSERT INTO "battle" VALUES ("3", "Battle of Trafalgar", "1805-10-21", "British victory");
INSERT INTO "battle" VALUES ("4", "Battle of Midway", "1942-06-04", "US victory");
INSERT INTO "battle" VALUES ("5", "Battle of Jutland", "1916-05-31", "Indecisive");
INSERT INTO "battle" VALUES ("6", "Battle of Lepanto", "1571-10-07", "Holy League victory");
INSERT INTO "battle" VALUES ("7", "Battle of Salamis", "480-09-29", "Greek victory");
INSERT INTO "battle" VALUES ("8", "Battle of the Philippine Sea", "1944-06-19", "US victory");
INSERT INTO "ship" VALUES ("1", "101");
INSERT INTO "ship" VALUES ("1", "102");
INSERT INTO "ship" VALUES ("2", "201");
INSERT INTO "ship" VALUES ("3", "301");
INSERT INTO "ship" VALUES ("3", "302");
INSERT INTO "ship" VALUES ("4", "401");
INSERT INTO "ship" VALUES ("5", "501");
INSERT INTO "ship" VALUES ("6", "601");
INSERT INTO "ship" VALUES ("7", "701");
INSERT INTO "ship" VALUES ("8", "801");
INSERT INTO "ship" VALUES ("8", "802");
INSERT INTO "death" VALUES ("101", "1001", "150", "30");
INSERT INTO "death" VALUES ("102", "1002", "200", "50");
INSERT INTO "death" VALUES ("201", "1003", "500", "100");
INSERT INTO "death" VALUES ("301", "1004", "300", "70");
INSERT INTO "death" VALUES ("302", "1005", "100", "20");
INSERT INTO "death" VALUES ("401", "1006", "400", "80");
INSERT INTO "death" VALUES ("501", "1007", "0", "0");
INSERT INTO "death" VALUES ("601", "1008", "250", "60");
INSERT INTO "death" VALUES ("701", "1009", "50", "10");
INSERT INTO "death" VALUES ("801", "1010", "600", "120");
INSERT INTO "death" VALUES ("802", "1011", "600", "130");