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,
"TG" INT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "Hypertension");
INSERT INTO "Patient" VALUES ("2", "Diabetes");
INSERT INTO "Patient" VALUES ("3", "Hyperlipidemia");
INSERT INTO "Patient" VALUES ("4", "Normal");
INSERT INTO "Patient" VALUES ("5", "Cardiovascular Disease");
INSERT INTO "Patient" VALUES ("6", "Obesity");
INSERT INTO "Patient" VALUES ("7", "Hypothyroidism");
INSERT INTO "Patient" VALUES ("8", "Kidney Disease");
INSERT INTO "Patient" VALUES ("9", "Pancreatitis");
INSERT INTO "Patient" VALUES ("10", "Metabolic Syndrome");
INSERT INTO "Examination" VALUES ("1", "2023-01-15", "Hypertension");
INSERT INTO "Examination" VALUES ("2", "2023-02-20", "Diabetes");
INSERT INTO "Examination" VALUES ("3", "2023-03-10", "Hyperlipidemia");
INSERT INTO "Examination" VALUES ("4", "2023-04-05", "Normal");
INSERT INTO "Examination" VALUES ("5", "2023-05-12", "Cardiovascular Disease");
INSERT INTO "Examination" VALUES ("6", "2023-06-01", "Obesity");
INSERT INTO "Examination" VALUES ("7", "2023-07-08", "Hypothyroidism");
INSERT INTO "Examination" VALUES ("8", "2023-08-19", "Kidney Disease");
INSERT INTO "Examination" VALUES ("9", "2023-09-25", "Pancreatitis");
INSERT INTO "Examination" VALUES ("10", "2023-10-30", "Metabolic Syndrome");
INSERT INTO "Examination" VALUES ("1", "2023-11-01", "Hypertension");
INSERT INTO "Examination" VALUES ("3", "2023-12-05", "Hyperlipidemia");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-16", "150");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-21", "250");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-11", "350");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-06", "90");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-13", "400");
INSERT INTO "Laboratory" VALUES ("6", "2023-06-02", "310");
INSERT INTO "Laboratory" VALUES ("7", "2023-07-09", "180");
INSERT INTO "Laboratory" VALUES ("8", "2023-08-20", "280");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-26", "500");
INSERT INTO "Laboratory" VALUES ("10", "2023-10-31", "320");
INSERT INTO "Laboratory" VALUES ("1", "2023-11-02", "305");
INSERT INTO "Laboratory" VALUES ("3", "2023-12-06", "290");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-14", "120");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-27", "200");