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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"RBC" FLOAT,
"HCT" FLOAT,
"IGA" INT,
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 "Laboratory" VALUES ("1", "2024-01-10", "4.5", "28.0", "120");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-10", "4.6", "30.0", "125");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-15", "4.7", "53.0", "130");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "4.8", "29.0", "110");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-25", "4.9", "55.0", "140");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-30", "5.0", "27.0", "135");
INSERT INTO "Examination" VALUES ("1", "50");
INSERT INTO "Examination" VALUES ("2", "80");
INSERT INTO "Examination" VALUES ("3", "60");
INSERT INTO "Examination" VALUES ("4", "90");
INSERT INTO "Examination" VALUES ("5", "85");