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,
"SEX" TEXT,
"Birthday" DATE,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "1937-05-10");
INSERT INTO "Patient" VALUES ("2", "F", "1937-11-22");
INSERT INTO "Patient" VALUES ("3", "M", "1938-01-15");
INSERT INTO "Patient" VALUES ("4", "F", "1937-03-01");
INSERT INTO "Patient" VALUES ("5", "M", "1936-09-12");
INSERT INTO "Patient" VALUES ("6", "F", "1937-07-07");
INSERT INTO "Patient" VALUES ("7", "M", "1937-02-28");
INSERT INTO "Patient" VALUES ("8", "F", "1939-04-04");
INSERT INTO "Laboratory" VALUES ("1", "2020-01-01", "260", "150");
INSERT INTO "Laboratory" VALUES ("1", "2020-06-15", "240", "140");
INSERT INTO "Laboratory" VALUES ("2", "2020-02-01", "270", "160");
INSERT INTO "Laboratory" VALUES ("3", "2020-03-01", "280", "170");
INSERT INTO "Laboratory" VALUES ("4", "2020-04-01", "230", "130");
INSERT INTO "Laboratory" VALUES ("4", "2020-08-20", "255", "155");
INSERT INTO "Laboratory" VALUES ("5", "2020-05-01", "265", "165");
INSERT INTO "Laboratory" VALUES ("6", "2020-06-01", "275", "175");
INSERT INTO "Laboratory" VALUES ("7", "2020-07-01", "245", "145");
INSERT INTO "Laboratory" VALUES ("7", "2020-10-10", "250", "150");
INSERT INTO "Laboratory" VALUES ("8", "2020-09-01", "290", "180");
INSERT INTO "Examination" VALUES ("Normal");
INSERT INTO "Examination" VALUES ("High Cholesterol");
INSERT INTO "Examination" VALUES ("Diabetes");
INSERT INTO "Examination" VALUES ("Hypertension");
INSERT INTO "Examination" VALUES ("Thrombosis Risk");