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,
"Examination Date" DATE,
"aCL IgG" FLOAT,
"aCL IgM" FLOAT,
"aCL IgA" INT,
"Diagnosis" TEXT,
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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

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



INSERT INTO "Patient" VALUES ("1");
INSERT INTO "Patient" VALUES ("2");
INSERT INTO "Patient" VALUES ("3");
INSERT INTO "Patient" VALUES ("4");
INSERT INTO "Patient" VALUES ("5");
INSERT INTO "Patient" VALUES ("6");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "14.5", "42.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-11", "12.0", "35.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-12", "10.0", "28.0");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-13", "16.0", "55.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-14", "13.0", "30.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-15", "11.5", "32.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-02-01", "9.5", "27.5");
INSERT INTO "Laboratory" VALUES ("4", "2023-02-02", "15.8", "53.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-02-03", "12.8", "29.5");
INSERT INTO "Examination" VALUES ("1", "2023-01-15", "10.5", "8.2", "15", "Normal");
INSERT INTO "Examination" VALUES ("2", "2023-01-16", "12.1", "9.5", "20", "Normal");
INSERT INTO "Examination" VALUES ("3", "2023-01-17", "15.0", "11.0", "35", "Thrombosis");
INSERT INTO "Examination" VALUES ("4", "2023-01-18", "18.0", "13.0", "40", "Thrombosis");
INSERT INTO "Examination" VALUES ("5", "2023-01-19", "11.0", "8.0", "25", "Normal");
INSERT INTO "Examination" VALUES ("6", "2023-01-20", "13.5", "10.0", "30", "Normal");
INSERT INTO "Examination" VALUES ("3", "2023-02-05", "16.5", "12.5", "45", "Thrombosis");
INSERT INTO "Examination" VALUES ("4", "2023-02-06", "19.0", "14.0", "50", "Thrombosis");
INSERT INTO "Examination" VALUES ("5", "2023-02-07", "11.5", "8.5", "28", "Normal");