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

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



INSERT INTO "Examination" VALUES ("Normal");
INSERT INTO "Examination" VALUES ("Elevated ALT");
INSERT INTO "Examination" VALUES ("Chronic Liver Disease");
INSERT INTO "Examination" VALUES ("Hepatitis");
INSERT INTO "Examination" VALUES ("Fatty Liver");
INSERT INTO "Patient" VALUES ("1", "M", "1950-05-20", "Normal");
INSERT INTO "Patient" VALUES ("2", "F", "1965-11-15", "Elevated ALT");
INSERT INTO "Patient" VALUES ("3", "M", "1980-01-30", "Chronic Liver Disease");
INSERT INTO "Patient" VALUES ("4", "F", "1995-07-10", "Hepatitis");
INSERT INTO "Patient" VALUES ("5", "M", "2000-12-05", "Fatty Liver");
INSERT INTO "Patient" VALUES ("6", "F", "1975-03-22", "Elevated ALT");
INSERT INTO "Patient" VALUES ("7", "M", "1960-08-18", "Normal");
INSERT INTO "Patient" VALUES ("8", "F", "1985-09-09", "Elevated ALT");
INSERT INTO "Patient" VALUES ("9", "M", "1990-04-25", "Fatty Liver");
INSERT INTO "Patient" VALUES ("10", "F", "2005-06-30", "Normal");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "30", "40");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-15", "25", "65");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-20", "50", "70");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-25", "45", "55");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-30", "60", "80");
INSERT INTO "Laboratory" VALUES ("6", "2023-06-05", "35", "61");
INSERT INTO "Laboratory" VALUES ("7", "2023-07-10", "20", "40");
INSERT INTO "Laboratory" VALUES ("8", "2023-08-15", "55", "90");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-20", "40", "59");
INSERT INTO "Laboratory" VALUES ("10", "2023-10-25", "30", "45");