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 "Laboratory" (
"ID" INT,
"Date" DATE,
"GOT" INT,
"GPT" INT,
"LDH" INT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"SEX" TEXT,
"Birthday" DATE,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "1970-05-20");
INSERT INTO "Patient" VALUES ("2", "F", "1985-11-15");
INSERT INTO "Patient" VALUES ("3", "M", "1990-01-30");
INSERT INTO "Patient" VALUES ("4", "F", "2000-07-10");
INSERT INTO "Patient" VALUES ("5", "M", "1960-12-05");
INSERT INTO "Laboratory" VALUES ("1", "2024-06-01", "30", "40", "610");
INSERT INTO "Laboratory" VALUES ("1", "2024-06-15", "32", "42", "590");
INSERT INTO "Laboratory" VALUES ("2", "2024-06-01", "28", "38", "700");
INSERT INTO "Laboratory" VALUES ("3", "2024-06-01", "35", "45", "800");
INSERT INTO "Laboratory" VALUES ("3", "2024-06-10", "33", "43", "810");
INSERT INTO "Laboratory" VALUES ("4", "2024-06-01", "25", "35", "599");
INSERT INTO "Laboratory" VALUES ("5", "2024-06-01", "40", "50", "750");
INSERT INTO "Laboratory" VALUES ("5", "2024-06-20", "42", "52", "770");
INSERT INTO "Laboratory" VALUES ("2", "2024-06-20", "29", "39", "580");