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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"HGB" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "M", "1980-05-10", "2020-01-15", "Thrombosis");
INSERT INTO "Patient" VALUES ("2", "F", "1992-11-22", "2021-03-01", "Anemia");
INSERT INTO "Patient" VALUES ("3", "M", "1975-01-01", "2019-07-20", "Healthy");
INSERT INTO "Patient" VALUES ("4", "F", "2000-03-15", "2022-09-10", "Thrombosis");
INSERT INTO "Patient" VALUES ("5", "M", "1965-08-01", "2018-04-05", "Diabetes");
INSERT INTO "Examination" VALUES ("1", "2022-02-01", "Deep Vein Thrombosis", "Leg pain, swelling");
INSERT INTO "Examination" VALUES ("2", "2022-04-10", "Iron Deficiency Anemia", "Fatigue, pallor");
INSERT INTO "Examination" VALUES ("3", "2022-01-05", "Routine Checkup", "None");
INSERT INTO "Examination" VALUES ("4", "2023-01-20", "Pulmonary Embolism", "Shortness of breath, chest pain");
INSERT INTO "Examination" VALUES ("5", "2022-03-01", "Diabetic Neuropathy", "Numbness in feet");
INSERT INTO "Examination" VALUES ("1", "2023-03-01", "Follow-up DVT", "Improved");
INSERT INTO "Laboratory" VALUES ("1", "2022-02-01", "13.5");
INSERT INTO "Laboratory" VALUES ("1", "2023-03-01", "14.0");
INSERT INTO "Laboratory" VALUES ("2", "2022-04-10", "9.8");
INSERT INTO "Laboratory" VALUES ("3", "2022-01-05", "15.2");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-20", "12.1");
INSERT INTO "Laboratory" VALUES ("5", "2022-03-01", "14.5");
INSERT INTO "Laboratory" VALUES ("1", "2021-12-15", "13.0");
INSERT INTO "Laboratory" VALUES ("3", "2021-06-01", "16.0");
INSERT INTO "Laboratory" VALUES ("4", "2022-10-01", "11.5");