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

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



INSERT INTO "Patient" VALUES ("48473");
INSERT INTO "Patient" VALUES ("10001");
INSERT INTO "Patient" VALUES ("20002");
INSERT INTO "Examination" VALUES ("48473", "2024-01-10");
INSERT INTO "Examination" VALUES ("48473", "2024-02-15");
INSERT INTO "Examination" VALUES ("10001", "2024-01-20");
INSERT INTO "Examination" VALUES ("20002", "2024-03-05");
INSERT INTO "Laboratory" VALUES ("48473", "2024-01-10", "55", "40");
INSERT INTO "Laboratory" VALUES ("48473", "2024-02-15", "60", "38");
INSERT INTO "Laboratory" VALUES ("48473", "2024-03-01", "75", "42");
INSERT INTO "Laboratory" VALUES ("10001", "2024-01-20", "45", "30");
INSERT INTO "Laboratory" VALUES ("20002", "2024-03-05", "59", "35");
INSERT INTO "Laboratory" VALUES ("20002", "2024-04-10", "61", "37");