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", "Victory");
INSERT INTO "battle" VALUES ("2", "Battle of Jutland", "1916-05-31", "Indecisive");
INSERT INTO "battle" VALUES ("3", "Battle of Midway", "1942-06-04", "Victory");
INSERT INTO "battle" VALUES ("4", "Battle of Lepanto", "1571-10-07", "Victory");
INSERT INTO "battle" VALUES ("5", "Battle of the Nile", "1798-08-01", "Victory");
INSERT INTO "ship" VALUES ("1", "101", "Lettice", "Frigate");
INSERT INTO "ship" VALUES ("1", "102", "HMS Atalanta", "Sloop");
INSERT INTO "ship" VALUES ("2", "103", "HMS Dreadnought", "Battleship");
INSERT INTO "ship" VALUES ("3", "104", "USS Yorktown", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("4", "105", "Santa Maria", "Galleon");
INSERT INTO "ship" VALUES ("5", "106", "HMS Vanguard", "Ship of the line");
INSERT INTO "ship" VALUES ("2", "107", "HMS Invincible", "Battlecruiser");
INSERT INTO "ship" VALUES ("3", "108", "USS Enterprise", "Aircraft Carrier");
INSERT INTO "ship" VALUES ("1", "109", "HMS Victory", "Ship of the line");
INSERT INTO "death" VALUES ("101", "201");
INSERT INTO "death" VALUES ("102", "202");
INSERT INTO "death" VALUES ("103", "203");
INSERT INTO "death" VALUES ("107", "204");
INSERT INTO "death" VALUES ("106", "205");