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,
"Admission" TEXT,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "1950-01-15", "2000-03-10", "Emergency", "SJS");
INSERT INTO "Patient" VALUES ("2", "F", "1965-05-20", "2005-07-22", "Outpatient", "SJS");
INSERT INTO "Patient" VALUES ("3", "M", "1972-11-01", "2010-01-05", "Inpatient", "Pneumonia");
INSERT INTO "Patient" VALUES ("4", "F", "1948-08-12", "1998-02-18", "Emergency", "SJS");
INSERT INTO "Patient" VALUES ("5", "M", "1980-03-25", "2015-09-01", "Outpatient", "Flu");
INSERT INTO "Patient" VALUES ("6", "F", "1955-06-30", "2002-04-15", "Inpatient", "SJS");
INSERT INTO "Patient" VALUES ("7", "M", "1960-09-10", "2008-11-20", "Emergency", "SJS");
INSERT INTO "Patient" VALUES ("8", "F", "1970-02-01", "2012-06-01", "Outpatient", "SJS");
INSERT INTO "Patient" VALUES ("9", "M", "1945-04-05", "1995-10-25", "Emergency", "SJS");
INSERT INTO "Patient" VALUES ("10", "F", "1985-12-12", "2018-01-30", "Inpatient", "Appendicitis");
INSERT INTO "Laboratory" VALUES ("1", "2000-03-15");
INSERT INTO "Laboratory" VALUES ("1", "2000-03-16");
INSERT INTO "Laboratory" VALUES ("2", "2005-07-25");
INSERT INTO "Laboratory" VALUES ("3", "2010-01-07");
INSERT INTO "Laboratory" VALUES ("4", "1998-02-20");
INSERT INTO "Laboratory" VALUES ("4", "1998-02-21");
INSERT INTO "Laboratory" VALUES ("5", "2015-09-03");
INSERT INTO "Laboratory" VALUES ("6", "2002-04-18");
INSERT INTO "Laboratory" VALUES ("7", "2008-11-22");
INSERT INTO "Laboratory" VALUES ("8", "2012-06-03");
INSERT INTO "Laboratory" VALUES ("9", "1995-10-28");
INSERT INTO "Laboratory" VALUES ("9", "1995-10-29");
INSERT INTO "Laboratory" VALUES ("10", "2018-02-01");
INSERT INTO "Examination" VALUES ("2000-03-10", "SJS");
INSERT INTO "Examination" VALUES ("2005-07-22", "SJS");
INSERT INTO "Examination" VALUES ("2010-01-05", "Pneumonia");
INSERT INTO "Examination" VALUES ("1998-02-18", "SJS");
INSERT INTO "Examination" VALUES ("2015-09-01", "Flu");
INSERT INTO "Examination" VALUES ("2002-04-15", "SJS");
INSERT INTO "Examination" VALUES ("2008-11-20", "SJS");
INSERT INTO "Examination" VALUES ("2012-06-01", "SJS");
INSERT INTO "Examination" VALUES ("1995-10-25", "SJS");
INSERT INTO "Examination" VALUES ("2018-01-30", "Appendicitis");