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" (
"ID" INT,
"Diagnosis" TEXT,
"Thrombosis" INT,
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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

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



INSERT INTO "Patient" VALUES ("1", "M");
INSERT INTO "Patient" VALUES ("2", "F");
INSERT INTO "Patient" VALUES ("3", "M");
INSERT INTO "Patient" VALUES ("4", "F");
INSERT INTO "Patient" VALUES ("5", "M");
INSERT INTO "Examination" VALUES ("1", "PSS", "1");
INSERT INTO "Examination" VALUES ("2", "Other", "0");
INSERT INTO "Examination" VALUES ("3", "PSS", "0");
INSERT INTO "Examination" VALUES ("4", "PSS", "1");
INSERT INTO "Examination" VALUES ("5", "Other", "1");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-15", "120", "28", "0.9", "7.0", "1.8");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-12", "130", "35", "1.2", "5.5", "3.0");
INSERT INTO "Laboratory" VALUES ("3", "2024-03-01", "123", "32", "1.0", "6.0", "2.1");
INSERT INTO "Laboratory" VALUES ("3", "2024-03-15", "125", "33", "1.1", "6.2", "1.9");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-20", "123", "29", "1.0", "6.8", "2.0");
INSERT INTO "Laboratory" VALUES ("4", "2024-02-20", "124", "30", "1.0", "6.9", "2.3");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-25", "110", "27", "0.8", "5.8", "1.5");