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" (
"Examination Date" DATE
);

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



INSERT INTO "Patient" VALUES ("1", "M", "1970-05-12", "2023-01-10");
INSERT INTO "Patient" VALUES ("2", "F", "1985-11-23", "2023-02-15");
INSERT INTO "Patient" VALUES ("3", "M", "1960-07-30", "2023-03-20");
INSERT INTO "Patient" VALUES ("4", "F", "1990-12-05", "2023-04-25");
INSERT INTO "Patient" VALUES ("5", "M", "1975-03-17", "2023-05-30");
INSERT INTO "Patient" VALUES ("6", "F", "1982-08-09", "2023-06-10");
INSERT INTO "Laboratory" VALUES ("1", "1994-01-15", "45", "30");
INSERT INTO "Laboratory" VALUES ("1", "1995-02-20", "70", "40");
INSERT INTO "Laboratory" VALUES ("2", "1994-03-10", "59", "35");
INSERT INTO "Laboratory" VALUES ("2", "1994-11-25", "61", "38");
INSERT INTO "Laboratory" VALUES ("3", "1994-06-05", "60", "50");
INSERT INTO "Laboratory" VALUES ("3", "1993-07-15", "55", "45");
INSERT INTO "Laboratory" VALUES ("4", "1994-09-30", "30", "25");
INSERT INTO "Laboratory" VALUES ("5", "1994-12-12", "59", "60");
INSERT INTO "Laboratory" VALUES ("5", "1994-12-15", "61", "62");
INSERT INTO "Laboratory" VALUES ("6", "1995-01-01", "50", "40");
INSERT INTO "Examination" VALUES ("1994-01-15");
INSERT INTO "Examination" VALUES ("1994-03-10");
INSERT INTO "Examination" VALUES ("1994-06-05");
INSERT INTO "Examination" VALUES ("1994-09-30");
INSERT INTO "Examination" VALUES ("1994-12-12");
INSERT INTO "Examination" VALUES ("1995-02-20");
INSERT INTO "Examination" VALUES ("1995-01-01");