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 "Examination" (
"Examination Date" DATE
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"LDH" INT,
"CRP" TEXT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "M", "2023-01-10");
INSERT INTO "Patient" VALUES ("2", "F", "2023-02-15");
INSERT INTO "Patient" VALUES ("3", "M", "2023-03-20");
INSERT INTO "Patient" VALUES ("4", "F", "2023-04-05");
INSERT INTO "Patient" VALUES ("5", "M", "2023-05-01");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-11", "450", "normal");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "480", "normal");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-16", "300", "normal");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-20", "320", "normal");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-21", "499", "normal");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-25", "510", "high");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-06", "600", "high");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-10", "580", "high");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-02", "480", "normal");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-05", "520", "high");
INSERT INTO "Examination" VALUES ("2023-01-11");
INSERT INTO "Examination" VALUES ("2023-01-15");
INSERT INTO "Examination" VALUES ("2023-02-16");
INSERT INTO "Examination" VALUES ("2023-02-20");
INSERT INTO "Examination" VALUES ("2023-03-21");
INSERT INTO "Examination" VALUES ("2023-03-25");
INSERT INTO "Examination" VALUES ("2023-04-06");
INSERT INTO "Examination" VALUES ("2023-04-10");
INSERT INTO "Examination" VALUES ("2023-05-02");
INSERT INTO "Examination" VALUES ("2023-05-05");