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

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

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



INSERT INTO "Patient" VALUES ("1", "1950-01-15");
INSERT INTO "Patient" VALUES ("2", "1960-05-20");
INSERT INTO "Patient" VALUES ("3", "1970-11-01");
INSERT INTO "Patient" VALUES ("4", "1980-03-10");
INSERT INTO "Patient" VALUES ("5", "1990-07-25");
INSERT INTO "Patient" VALUES ("6", "1945-09-12");
INSERT INTO "Patient" VALUES ("7", "1955-02-28");
INSERT INTO "Patient" VALUES ("8", "1965-06-05");
INSERT INTO "Patient" VALUES ("9", "1975-12-18");
INSERT INTO "Patient" VALUES ("10", "1985-04-03");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "120");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-15", "190");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-20", "150");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-01", "200");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-05", "160");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-10", "175");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-05", "210");
INSERT INTO "Laboratory" VALUES ("7", "2023-02-20", "130");
INSERT INTO "Laboratory" VALUES ("8", "2023-03-15", "195");
INSERT INTO "Laboratory" VALUES ("9", "2023-04-20", "140");
INSERT INTO "Laboratory" VALUES ("10", "2023-05-25", "185");
INSERT INTO "Laboratory" VALUES ("1", "2023-03-01", "170");
INSERT INTO "Laboratory" VALUES ("6", "2023-02-01", "150");
INSERT INTO "Laboratory" VALUES ("8", "2023-04-01", "160");
INSERT INTO "Examination" VALUES ("1", "2023-01-12", "Normal");
INSERT INTO "Examination" VALUES ("1", "2023-02-17", "Diabetes");
INSERT INTO "Examination" VALUES ("2", "2023-01-22", "Normal");
INSERT INTO "Examination" VALUES ("3", "2023-03-03", "Diabetes");
INSERT INTO "Examination" VALUES ("4", "2023-04-07", "Normal");
INSERT INTO "Examination" VALUES ("5", "2023-05-12", "Normal");
INSERT INTO "Examination" VALUES ("6", "2023-01-07", "Diabetes");
INSERT INTO "Examination" VALUES ("7", "2023-02-22", "Normal");
INSERT INTO "Examination" VALUES ("8", "2023-03-17", "Diabetes");
INSERT INTO "Examination" VALUES ("9", "2023-04-22", "Normal");
INSERT INTO "Examination" VALUES ("10", "2023-05-27", "Diabetes");