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

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("30609", "Deep Vein Thrombosis");
INSERT INTO "Patient" VALUES ("10234", "Pulmonary Embolism");
INSERT INTO "Patient" VALUES ("45012", "No Thrombosis");
INSERT INTO "Patient" VALUES ("78901", "Superficial Thrombophlebitis");
INSERT INTO "Examination" VALUES ("30609", "2023-01-15", "Deep Vein Thrombosis");
INSERT INTO "Examination" VALUES ("30609", "2023-03-20", "Deep Vein Thrombosis");
INSERT INTO "Examination" VALUES ("10234", "2023-02-10", "Pulmonary Embolism");
INSERT INTO "Examination" VALUES ("45012", "2023-01-05", "No Thrombosis");
INSERT INTO "Examination" VALUES ("78901", "2023-04-12", "Superficial Thrombophlebitis");
INSERT INTO "Laboratory" VALUES ("30609", "2023-01-10");
INSERT INTO "Laboratory" VALUES ("30609", "2023-02-15");
INSERT INTO "Laboratory" VALUES ("30609", "2023-03-18");
INSERT INTO "Laboratory" VALUES ("10234", "2023-02-05");
INSERT INTO "Laboratory" VALUES ("45012", "2023-01-02");
INSERT INTO "Laboratory" VALUES ("78901", "2023-04-10");