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" (
"Examination Date" DATE,
"Diagnosis" TEXT
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
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", "1940-05-12", "2010-03-15", "SJS");
INSERT INTO "Patient" VALUES ("2", "F", "1955-11-30", "2012-07-20", "SJS");
INSERT INTO "Patient" VALUES ("3", "F", "1935-01-25", "2009-01-10", "SJS");
INSERT INTO "Patient" VALUES ("4", "M", "1960-08-05", "2015-05-05", "Other");
INSERT INTO "Patient" VALUES ("5", "F", "1945-12-15", "2011-11-11", "SJS");
INSERT INTO "Patient" VALUES ("6", "M", "1930-03-02", "2008-09-09", "Other");
INSERT INTO "Laboratory" VALUES ("1", "2010-03-16");
INSERT INTO "Laboratory" VALUES ("2", "2012-07-21");
INSERT INTO "Laboratory" VALUES ("3", "2009-01-11");
INSERT INTO "Laboratory" VALUES ("5", "2011-11-12");
INSERT INTO "Examination" VALUES ("2010-03-15", "SJS");
INSERT INTO "Examination" VALUES ("2012-07-20", "SJS");
INSERT INTO "Examination" VALUES ("2009-01-10", "SJS");
INSERT INTO "Examination" VALUES ("2015-05-05", "Other");
INSERT INTO "Examination" VALUES ("2011-11-11", "SJS");