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 "Patient" VALUES ("1", "M", "1950-05-20", "Chronic Hepatitis");
INSERT INTO "Patient" VALUES ("2", "F", "1980-11-15", "Fatty Liver");
INSERT INTO "Patient" VALUES ("3", "M", "1975-07-30", "Normal");
INSERT INTO "Patient" VALUES ("4", "F", "1990-01-10", "Acute Hepatitis");
INSERT INTO "Patient" VALUES ("5", "M", "1965-03-05", "Cirrhosis");
INSERT INTO "Patient" VALUES ("6", "F", "2000-12-25", "Normal");
INSERT INTO "Patient" VALUES ("7", "M", "1985-08-08", "Fatty Liver");
INSERT INTO "Patient" VALUES ("8", "F", "1955-09-17", "Borderline GPT");
INSERT INTO "Patient" VALUES ("9", "M", "1995-04-22", "Normal");
INSERT INTO "Patient" VALUES ("10", "F", "1970-06-14", "Chronic Hepatitis");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-01", "30", "58");
INSERT INTO "Laboratory" VALUES ("1", "2023-06-01", "32", "62");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-15", "28", "61");
INSERT INTO "Laboratory" VALUES ("2", "2023-07-15", "29", "59");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-10", "25", "45");
INSERT INTO "Laboratory" VALUES ("3", "2023-08-10", "27", "50");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-05", "40", "75");
INSERT INTO "Laboratory" VALUES ("4", "2023-09-05", "38", "80");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-20", "35", "60");
INSERT INTO "Laboratory" VALUES ("5", "2023-06-20", "36", "65");
INSERT INTO "Laboratory" VALUES ("6", "2023-05-01", "20", "40");
INSERT INTO "Laboratory" VALUES ("6", "2023-10-01", "22", "42");
INSERT INTO "Laboratory" VALUES ("7", "2023-03-15", "33", "61");
INSERT INTO "Laboratory" VALUES ("7", "2023-08-15", "34", "63");
INSERT INTO "Laboratory" VALUES ("8", "2023-02-01", "30", "60");
INSERT INTO "Laboratory" VALUES ("8", "2023-07-01", "31", "59");
INSERT INTO "Laboratory" VALUES ("9", "2023-04-25", "28", "55");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-25", "29", "58");
INSERT INTO "Laboratory" VALUES ("10", "2023-01-30", "37", "70");
INSERT INTO "Laboratory" VALUES ("10", "2023-06-30", "38", "68");