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,
"UN" INT,
"CRE" FLOAT,
"U-PRO" TEXT,
"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 "Examination" VALUES ("1", "50");
INSERT INTO "Examination" VALUES ("2", "80");
INSERT INTO "Examination" VALUES ("3", "80");
INSERT INTO "Examination" VALUES ("4", "30");
INSERT INTO "Examination" VALUES ("5", "60");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "20", "1.2", "Negative", "100");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-11", "18", "1.4", "Trace", "110");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-12", "22", "1.6", "Negative", "90");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-13", "19", "1.3", "Positive", "95");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-14", "21", "1.1", "Negative", "105");