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



INSERT INTO "Patient" VALUES ("1", "M");
INSERT INTO "Patient" VALUES ("2", "F");
INSERT INTO "Patient" VALUES ("3", "M");
INSERT INTO "Patient" VALUES ("4", "M");
INSERT INTO "Patient" VALUES ("5", "F");
INSERT INTO "Patient" VALUES ("6", "M");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "30", "55");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-15", "28", "62");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-12", "40", "45");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-01", "35", "59");
INSERT INTO "Laboratory" VALUES ("3", "2023-04-01", "33", "61");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-20", "25", "60");
INSERT INTO "Laboratory" VALUES ("4", "2023-02-20", "27", "58");
INSERT INTO "Laboratory" VALUES ("5", "2023-03-15", "30", "70");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-05", "20", "59");
INSERT INTO "Laboratory" VALUES ("6", "2023-02-05", "22", "61");
INSERT INTO "Examination" VALUES ("2023-01-10");
INSERT INTO "Examination" VALUES ("2023-02-15");
INSERT INTO "Examination" VALUES ("2023-01-12");
INSERT INTO "Examination" VALUES ("2023-03-01");
INSERT INTO "Examination" VALUES ("2023-04-01");
INSERT INTO "Examination" VALUES ("2023-01-20");
INSERT INTO "Examination" VALUES ("2023-02-20");
INSERT INTO "Examination" VALUES ("2023-03-15");
INSERT INTO "Examination" VALUES ("2023-01-05");
INSERT INTO "Examination" VALUES ("2023-02-05");