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

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

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



INSERT INTO "Patient" VALUES ("1", "M", "Thrombosis");
INSERT INTO "Patient" VALUES ("2", "F", "Healthy");
INSERT INTO "Patient" VALUES ("3", "M", "Autoimmune Disease");
INSERT INTO "Patient" VALUES ("4", "F", "Thrombosis");
INSERT INTO "Patient" VALUES ("5", "M", "Healthy");
INSERT INTO "Patient" VALUES ("6", "F", "Other Condition");
INSERT INTO "Patient" VALUES ("7", "M", "Thrombosis");
INSERT INTO "Patient" VALUES ("8", "F", "Healthy");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "600");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-16", "450");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-17", "70");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-18", "300");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-19", "500");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-20", "80");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-21", "550");
INSERT INTO "Laboratory" VALUES ("8", "2023-01-22", "499");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-01", "480");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-02", "90");
INSERT INTO "Laboratory" VALUES ("5", "2023-02-03", "490");
INSERT INTO "Examination" VALUES ("1", "550", "Thrombosis", "Leg pain");
INSERT INTO "Examination" VALUES ("2", "400", "Healthy", "None");
INSERT INTO "Examination" VALUES ("3", "60", "Autoimmune Disease", "Joint pain");
INSERT INTO "Examination" VALUES ("4", "280", "Thrombosis", "Chest pain");
INSERT INTO "Examination" VALUES ("5", "490", "Healthy", "None");
INSERT INTO "Examination" VALUES ("6", "75", "Other Condition", "Fatigue");
INSERT INTO "Examination" VALUES ("7", "520", "Thrombosis", "Shortness of breath");
INSERT INTO "Examination" VALUES ("8", "495", "Healthy", "None");