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,
PRIMARY KEY ("id"),
FOREIGN KEY ("caused_by_ship_id") REFERENCES "ship"("id")
);

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





INSERT INTO "battle" VALUES ("1", "Battle of Trafalgar", "1805-10-21", "Decisive British victory");
INSERT INTO "battle" VALUES ("2", "Battle of Jutland", "1916-05-31", "Inconclusive");
INSERT INTO "battle" VALUES ("3", "Battle of the Atlantic", "1939-09-01", "Allied victory");
INSERT INTO "battle" VALUES ("4", "Battle of Midway", "1942-06-04", "Decisive American victory");
INSERT INTO "battle" VALUES ("5", "Battle of Cape Matapan", "1941-03-28", "Decisive British victory");
INSERT INTO "battle" VALUES ("6", "Battle of the River Plate", "1939-12-13", "British victory");
INSERT INTO "ship" VALUES ("1", "101", "HMS Victory", "Ship of the line");
INSERT INTO "ship" VALUES ("1", "102", "Redoutable", "Ship of the line");
INSERT INTO "ship" VALUES ("2", "201", "HMS Invincible", "Battlecruiser");
INSERT INTO "ship" VALUES ("2", "202", "SMS Lützow", "Battlecruiser");
INSERT INTO "ship" VALUES ("3", "301", "Lettice", "Merchant ship");
INSERT INTO "ship" VALUES ("3", "302", "U-47", "Submarine");
INSERT INTO "ship" VALUES ("4", "401", "USS Yorktown", "Aircraft carrier");
INSERT INTO "ship" VALUES ("4", "402", "Akagi", "Aircraft carrier");
INSERT INTO "ship" VALUES ("5", "501", "HMS Gloucester", "Light cruiser");
INSERT INTO "ship" VALUES ("5", "502", "HMS Atalanta", "Light cruiser");
INSERT INTO "ship" VALUES ("6", "601", "HMS Exeter", "Heavy cruiser");
INSERT INTO "ship" VALUES ("6", "602", "Admiral Graf Spee", "Pocket battleship");
INSERT INTO "death" VALUES ("102", "1");
INSERT INTO "death" VALUES ("201", "2");
INSERT INTO "death" VALUES ("202", "3");
INSERT INTO "death" VALUES ("301", "4");
INSERT INTO "death" VALUES ("302", "5");
INSERT INTO "death" VALUES ("401", "6");
INSERT INTO "death" VALUES ("402", "7");
INSERT INTO "death" VALUES ("501", "8");
INSERT INTO "death" VALUES ("502", "9");
INSERT INTO "death" VALUES ("602", "10");