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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"T-CHO" INT,
"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 "Examination" VALUES ("Hypertension");
INSERT INTO "Examination" VALUES ("Diabetes");
INSERT INTO "Examination" VALUES ("Hyperlipidemia");
INSERT INTO "Examination" VALUES ("Healthy");
INSERT INTO "Patient" VALUES ("1", "Hypertension");
INSERT INTO "Patient" VALUES ("2", "Diabetes");
INSERT INTO "Patient" VALUES ("3", "Hyperlipidemia");
INSERT INTO "Patient" VALUES ("4", "Healthy");
INSERT INTO "Patient" VALUES ("5", "Diabetes");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "180", "150");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-10", "190", "199");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-15", "210", "180");
INSERT INTO "Laboratory" VALUES ("2", "2024-03-15", "220", "170");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "230", "199");
INSERT INTO "Laboratory" VALUES ("3", "2024-02-20", "240", "201");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-25", "200", "100");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-30", "195", "199");
INSERT INTO "Laboratory" VALUES ("5", "2024-02-28", "185", "198");