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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
PRIMARY KEY ("ID", "Date")
);

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"Birthday" DATE,
"First Date" DATE,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("821298", "1980-05-10", "2023-01-15");
INSERT INTO "Patient" VALUES ("100001", "1992-11-22", "2023-02-01");
INSERT INTO "Patient" VALUES ("200002", "1975-03-01", "2023-01-20");
INSERT INTO "Patient" VALUES ("300003", "2000-07-18", "2023-03-10");
INSERT INTO "Patient" VALUES ("400004", "1965-09-05", "2023-01-05");
INSERT INTO "Examination" VALUES ("821298", "2023-01-17", "Initial Evaluation");
INSERT INTO "Examination" VALUES ("100001", "2023-02-05", "Follow-up");
INSERT INTO "Examination" VALUES ("200002", "2023-01-20", "Emergency");
INSERT INTO "Examination" VALUES ("821298", "2023-01-25", "Further Tests");
INSERT INTO "Examination" VALUES ("400004", "2023-01-06", "Routine Check");
INSERT INTO "Laboratory" VALUES ("821298", "2023-01-18");
INSERT INTO "Laboratory" VALUES ("100001", "2023-02-06");
INSERT INTO "Laboratory" VALUES ("200002", "2023-01-21");
INSERT INTO "Laboratory" VALUES ("821298", "2023-01-26");
INSERT INTO "Laboratory" VALUES ("400004", "2023-01-07");