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,
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");
INSERT INTO "battle" VALUES ("2", "Battle of the Nile", "1798-08-01");
INSERT INTO "battle" VALUES ("3", "Battle of Jutland", "1916-05-31");
INSERT INTO "battle" VALUES ("4", "Battle of Midway", "1942-06-04");
INSERT INTO "battle" VALUES ("5", "Battle of Lepanto", "1571-10-07");
INSERT INTO "ship" VALUES ("1", "101", "HMS Victory", "Ship of the line");
INSERT INTO "ship" VALUES ("1", "102", "HMS Euryalus", "Frigate");
INSERT INTO "ship" VALUES ("1", "103", "HMS Nautilus", "Brig");
INSERT INTO "ship" VALUES ("2", "201", "HMS Vanguard", "Ship of the line");
INSERT INTO "ship" VALUES ("2", "202", "HMS Mutine", "Brig");
INSERT INTO "ship" VALUES ("3", "301", "HMS Queen Mary", "Battlecruiser");
INSERT INTO "ship" VALUES ("3", "302", "HMS Ardent", "Destroyer");
INSERT INTO "ship" VALUES ("4", "401", "USS Yorktown", "Aircraft carrier");
INSERT INTO "ship" VALUES ("4", "402", "USS Hammann", "Destroyer");
INSERT INTO "ship" VALUES ("5", "501", "Real", "Galley");
INSERT INTO "ship" VALUES ("5", "502", "San Lorenzo", "Brig");
INSERT INTO "death" VALUES ("103", "1001");
INSERT INTO "death" VALUES ("202", "1002");
INSERT INTO "death" VALUES ("302", "1003");
INSERT INTO "death" VALUES ("502", "1004");