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 "Patient" VALUES ("6");
INSERT INTO "Patient" VALUES ("7");
INSERT INTO "Patient" VALUES ("8");
INSERT INTO "Patient" VALUES ("9");
INSERT INTO "Patient" VALUES ("10");
INSERT INTO "Examination" VALUES ("1", "120");
INSERT INTO "Examination" VALUES ("2", "150");
INSERT INTO "Examination" VALUES ("3", "150");
INSERT INTO "Examination" VALUES ("4", "130");
INSERT INTO "Examination" VALUES ("5", "140");
INSERT INTO "Examination" VALUES ("6", "150");
INSERT INTO "Examination" VALUES ("7", "110");
INSERT INTO "Examination" VALUES ("8", "90");
INSERT INTO "Examination" VALUES ("9", "150");
INSERT INTO "Examination" VALUES ("10", "100");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "20", "1.4", "neg", "15");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-10", "22", "1.6", "trace", "16");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-15", "18", "1.5", "neg", "14");
INSERT INTO "Laboratory" VALUES ("2", "2024-03-15", "19", "1.4", "neg", "15");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "25", "1.3", "pos", "20");
INSERT INTO "Laboratory" VALUES ("3", "2024-02-20", "24", "1.7", "pos", "21");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-25", "30", "1.2", "neg", "18");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-30", "28", "1.8", "trace", "17");
INSERT INTO "Laboratory" VALUES ("6", "2024-02-05", "22", "1.49", "neg", "19");
INSERT INTO "Laboratory" VALUES ("6", "2024-03-05", "23", "1.6", "pos", "20");
INSERT INTO "Laboratory" VALUES ("7", "2024-02-10", "21", "1.0", "neg", "13");
INSERT INTO "Laboratory" VALUES ("8", "2024-02-15", "19", "1.4", "neg", "12");
INSERT INTO "Laboratory" VALUES ("9", "2024-02-20", "20", "1.3", "neg", "15");
INSERT INTO "Laboratory" VALUES ("9", "2024-03-20", "21", "1.2", "neg", "16");
INSERT INTO "Laboratory" VALUES ("10", "2024-02-25", "17", "1.6", "trace", "14");