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,
"GOT" INT,
"GPT" INT,
"ALP" 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 "Examination" VALUES ("Normal");
INSERT INTO "Examination" VALUES ("Thrombosis");
INSERT INTO "Examination" VALUES ("High Blood Pressure");
INSERT INTO "Examination" VALUES ("Diabetes");
INSERT INTO "Examination" VALUES ("Normal");
INSERT INTO "Patient" VALUES ("1", "M", "1980-01-15");
INSERT INTO "Patient" VALUES ("2", "F", "1992-05-20");
INSERT INTO "Patient" VALUES ("3", "M", "1975-11-01");
INSERT INTO "Patient" VALUES ("4", "F", "1988-03-10");
INSERT INTO "Patient" VALUES ("5", "M", "1995-07-22");
INSERT INTO "Patient" VALUES ("6", "M", "1970-02-28");
INSERT INTO "Patient" VALUES ("7", "F", "1985-09-12");
INSERT INTO "Patient" VALUES ("8", "M", "1990-04-05");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "55", "40", "100");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-15", "65", "45", "110");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-10", "50", "35", "90");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-10", "58", "42", "95");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-01", "70", "50", "120");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-10", "62", "48", "105");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-10", "59", "41", "98");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-10", "50", "38", "92");
INSERT INTO "Laboratory" VALUES ("6", "2023-02-20", "55", "40", "95");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-10", "60", "43", "102");
INSERT INTO "Laboratory" VALUES ("8", "2023-01-10", "52", "39", "93");
INSERT INTO "Laboratory" VALUES ("8", "2023-03-05", "57", "41", "96");