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 for British");
INSERT INTO "battle" VALUES ("2", "Battle of Jutland", "1916-05-31", "Indecisive");
INSERT INTO "battle" VALUES ("3", "Battle of the Nile", "1798-08-01", "Victory for British");
INSERT INTO "battle" VALUES ("4", "Battle of Camperdown", "1797-10-11", "Victory for British");
INSERT INTO "battle" VALUES ("5", "Battle of Copenhagen", "1801-04-02", "Victory for British");
INSERT INTO "ship" VALUES ("10", "1", "Lettice", "Frigate");
INSERT INTO "ship" VALUES ("11", "2", "HMS Atalanta", "Sloop");
INSERT INTO "ship" VALUES ("12", "3", "HMS Victory", "Ship of the line");
INSERT INTO "ship" VALUES ("13", "NULL", "HMS Dreadnought", "Battleship");
INSERT INTO "ship" VALUES ("14", "4", "HMS Bellerophon", "Ship of the line");
INSERT INTO "ship" VALUES ("15", "5", "HMS Elephant", "Ship of the line");
INSERT INTO "death" VALUES ("10", "100");
INSERT INTO "death" VALUES ("11", "101");
INSERT INTO "death" VALUES ("14", "102");