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,
"Diagnosis" TEXT
);

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

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



INSERT INTO "Examination" VALUES ("2023-01-15", "Normal");
INSERT INTO "Examination" VALUES ("2023-02-20", "High Blood Pressure");
INSERT INTO "Examination" VALUES ("2023-03-10", "Diabetes");
INSERT INTO "Examination" VALUES ("2023-04-05", "High Cholesterol");
INSERT INTO "Examination" VALUES ("2023-05-01", "Normal");
INSERT INTO "Examination" VALUES ("2023-06-12", "Pre-diabetes");
INSERT INTO "Examination" VALUES ("2023-07-25", "Normal");
INSERT INTO "Examination" VALUES ("2023-08-30", "High Blood Pressure");
INSERT INTO "Examination" VALUES ("2023-09-18", "Normal");
INSERT INTO "Examination" VALUES ("2023-10-07", "Diabetes");
INSERT INTO "Patient" VALUES ("1", "M", "1980-05-10", "2022-01-01");
INSERT INTO "Patient" VALUES ("2", "F", "1975-11-22", "2022-03-15");
INSERT INTO "Patient" VALUES ("3", "M", "1990-03-01", "2022-06-01");
INSERT INTO "Patient" VALUES ("4", "F", "1965-08-14", "2022-09-01");
INSERT INTO "Patient" VALUES ("5", "M", "1988-01-20", "2022-11-01");
INSERT INTO "Patient" VALUES ("6", "F", "1995-07-07", "2023-01-01");
INSERT INTO "Patient" VALUES ("7", "M", "1970-04-03", "2023-02-01");
INSERT INTO "Patient" VALUES ("8", "F", "1982-12-12", "2023-03-01");
INSERT INTO "Patient" VALUES ("9", "M", "1960-02-29", "2023-04-01");
INSERT INTO "Patient" VALUES ("10", "F", "1999-09-09", "2023-05-01");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "200", "90");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-20", "260", "110");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-10", "220", "190");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-05", "280", "100");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-01", "210", "170");
INSERT INTO "Laboratory" VALUES ("6", "2023-06-12", "230", "185");
INSERT INTO "Laboratory" VALUES ("7", "2023-07-25", "190", "95");
INSERT INTO "Laboratory" VALUES ("8", "2023-08-30", "270", "120");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-18", "240", "160");
INSERT INTO "Laboratory" VALUES ("10", "2023-10-07", "205", "200");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-01", "215", "105");
INSERT INTO "Laboratory" VALUES ("3", "2023-04-01", "235", "175");
INSERT INTO "Laboratory" VALUES ("5", "2023-06-01", "245", "195");
INSERT INTO "Laboratory" VALUES ("6", "2023-07-01", "225", "170");
INSERT INTO "Laboratory" VALUES ("10", "2023-11-01", "210", "180");