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

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

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"SEX" TEXT,
"First Date" DATE,
"Admission" TEXT,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "2023-01-10", "ER", "AORTITIS");
INSERT INTO "Patient" VALUES ("2", "F", "2023-01-12", "ER", "THROMBOSIS");
INSERT INTO "Patient" VALUES ("3", "F", "2023-01-15", "ICU", "AORTITIS");
INSERT INTO "Patient" VALUES ("4", "M", "2023-01-20", "ER", "AORTITIS");
INSERT INTO "Patient" VALUES ("5", "F", "2023-01-25", "Ward", "OTHER");
INSERT INTO "Examination" VALUES ("1", "2023-01-11", "AORTITIS", "0");
INSERT INTO "Examination" VALUES ("2", "2023-01-13", "THROMBOSIS", "1");
INSERT INTO "Examination" VALUES ("3", "2023-01-16", "AORTITIS", "0");
INSERT INTO "Examination" VALUES ("4", "2023-01-21", "AORTITIS", "1");
INSERT INTO "Examination" VALUES ("5", "2023-01-26", "OTHER", "0");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-11");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-13");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-16");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-21");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-26");