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" (
"Examination Date" DATE
);

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

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



INSERT INTO "Examination" VALUES ("1989-05-10");
INSERT INTO "Examination" VALUES ("1991-03-15");
INSERT INTO "Examination" VALUES ("1992-07-20");
INSERT INTO "Examination" VALUES ("1995-01-01");
INSERT INTO "Examination" VALUES ("1998-11-22");
INSERT INTO "Examination" VALUES ("2000-02-29");
INSERT INTO "Examination" VALUES ("2005-06-01");
INSERT INTO "Examination" VALUES ("2010-09-10");
INSERT INTO "Examination" VALUES ("2015-12-25");
INSERT INTO "Examination" VALUES ("2020-04-04");
INSERT INTO "Patient" VALUES ("1", "1988-01-01");
INSERT INTO "Patient" VALUES ("2", "1990-01-01");
INSERT INTO "Patient" VALUES ("3", "1990-01-02");
INSERT INTO "Patient" VALUES ("4", "1991-05-10");
INSERT INTO "Patient" VALUES ("5", "1992-03-15");
INSERT INTO "Patient" VALUES ("6", "1995-07-20");
INSERT INTO "Patient" VALUES ("7", "1999-01-01");
INSERT INTO "Patient" VALUES ("8", "2000-11-22");
INSERT INTO "Patient" VALUES ("9", "2005-02-29");
INSERT INTO "Patient" VALUES ("10", "2010-06-01");
INSERT INTO "Laboratory" VALUES ("1", "1988-01-01", "100", "70", "50");
INSERT INTO "Laboratory" VALUES ("2", "1990-01-01", "120", "90", "60");
INSERT INTO "Laboratory" VALUES ("3", "1990-01-02", "150", "100", "70");
INSERT INTO "Laboratory" VALUES ("4", "1991-05-10", "200", "450", "80");
INSERT INTO "Laboratory" VALUES ("5", "1992-03-15", "250", "500", "90");
INSERT INTO "Laboratory" VALUES ("6", "1995-07-20", "300", "85", "100");
INSERT INTO "Laboratory" VALUES ("7", "1999-01-01", "350", "50", "110");
INSERT INTO "Laboratory" VALUES ("8", "2000-11-22", "400", "499", "120");
INSERT INTO "Laboratory" VALUES ("9", "2005-02-29", "450", "81", "130");
INSERT INTO "Laboratory" VALUES ("10", "2010-06-01", "500", "501", "140");
INSERT INTO "Laboratory" VALUES ("2", "1990-02-01", "130", "110", "65");
INSERT INTO "Laboratory" VALUES ("3", "1990-03-01", "160", "75", "75");
INSERT INTO "Laboratory" VALUES ("4", "1991-06-01", "210", "400", "85");
INSERT INTO "Laboratory" VALUES ("5", "1992-04-01", "260", "510", "95");
INSERT INTO "Laboratory" VALUES ("6", "1995-08-01", "310", "90", "105");