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,
"Symptoms" TEXT,
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,
"Birthday" DATE,
"First Date" DATE,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("163109", "F", "1980-05-15", "2020-01-10");
INSERT INTO "Patient" VALUES ("163110", "M", "1975-11-22", "2019-03-01");
INSERT INTO "Patient" VALUES ("163111", "F", "1992-08-03", "2021-07-18");
INSERT INTO "Patient" VALUES ("163112", "M", "1968-02-29", "2018-09-05");
INSERT INTO "Patient" VALUES ("163113", "F", "1985-01-01", "2022-04-12");
INSERT INTO "Examination" VALUES ("163109", "2022-03-20", "Chest Pain");
INSERT INTO "Examination" VALUES ("163110", "2021-11-01", "Shortness of Breath");
INSERT INTO "Examination" VALUES ("163111", "2022-01-15", "Leg Swelling");
INSERT INTO "Examination" VALUES ("163109", "2022-04-05", "Dizziness");
INSERT INTO "Examination" VALUES ("163112", "2020-06-10", "Headache");
INSERT INTO "Laboratory" VALUES ("163109", "2022-03-20");
INSERT INTO "Laboratory" VALUES ("163110", "2021-11-01");
INSERT INTO "Laboratory" VALUES ("163111", "2022-01-15");
INSERT INTO "Laboratory" VALUES ("163109", "2022-04-05");
INSERT INTO "Laboratory" VALUES ("163112", "2020-06-10");