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", "1959-02-18");
INSERT INTO "Patient" VALUES ("2", "F", "1960-05-10");
INSERT INTO "Patient" VALUES ("3", "M", "1959-02-18");
INSERT INTO "Patient" VALUES ("4", "F", "1970-11-23");
INSERT INTO "Laboratory" VALUES ("1", "1981-11-05", "220", "150");
INSERT INTO "Laboratory" VALUES ("1", "1981-11-20", "210", "140");
INSERT INTO "Laboratory" VALUES ("1", "1981-12-01", "180", "130");
INSERT INTO "Laboratory" VALUES ("1", "1981-12-15", "170", "120");
INSERT INTO "Laboratory" VALUES ("2", "1981-11-10", "190", "110");
INSERT INTO "Laboratory" VALUES ("2", "1981-12-10", "185", "105");
INSERT INTO "Laboratory" VALUES ("3", "1981-11-12", "230", "160");
INSERT INTO "Laboratory" VALUES ("3", "1981-12-12", "210", "150");
INSERT INTO "Laboratory" VALUES ("4", "1981-11-25", "200", "140");
INSERT INTO "Laboratory" VALUES ("4", "1981-12-25", "195", "135");
INSERT INTO "Examination" VALUES ("Normal");