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,
"T-BIL" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "1990-01-15", "-");
INSERT INTO "Patient" VALUES ("2", "1991-03-20", "Inpatient");
INSERT INTO "Patient" VALUES ("3", "1991-09-01", "-");
INSERT INTO "Patient" VALUES ("4", "1992-02-10", "-");
INSERT INTO "Patient" VALUES ("5", "1991-10-05", "Emergency");
INSERT INTO "Patient" VALUES ("6", "1990-05-22", "-");
INSERT INTO "Patient" VALUES ("7", "1991-08-12", "Inpatient");
INSERT INTO "Patient" VALUES ("8", "1991-10-15", "-");
INSERT INTO "Patient" VALUES ("9", "1991-07-01", "-");
INSERT INTO "Patient" VALUES ("10", "1992-01-01", "Inpatient");
INSERT INTO "Laboratory" VALUES ("1", "1991-10-10", "1.5");
INSERT INTO "Laboratory" VALUES ("1", "1991-11-01", "2.1");
INSERT INTO "Laboratory" VALUES ("2", "1991-10-12", "1.8");
INSERT INTO "Laboratory" VALUES ("3", "1991-10-05", "1.2");
INSERT INTO "Laboratory" VALUES ("3", "1991-09-28", "2.5");
INSERT INTO "Laboratory" VALUES ("4", "1991-10-20", "0.9");
INSERT INTO "Laboratory" VALUES ("4", "1992-01-05", "1.1");
INSERT INTO "Laboratory" VALUES ("5", "1991-10-08", "3.0");
INSERT INTO "Laboratory" VALUES ("6", "1991-10-15", "1.7");
INSERT INTO "Laboratory" VALUES ("7", "1991-10-25", "1.9");
INSERT INTO "Laboratory" VALUES ("8", "1991-10-01", "0.8");
INSERT INTO "Laboratory" VALUES ("9", "1991-10-30", "1.6");
INSERT INTO "Laboratory" VALUES ("9", "1991-11-10", "2.0");
INSERT INTO "Laboratory" VALUES ("10", "1991-10-03", "2.2");
INSERT INTO "Examination" VALUES ("1991-10-10", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-12", "Elevated T-BIL");
INSERT INTO "Examination" VALUES ("1991-10-05", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-20", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-08", "Elevated T-BIL");
INSERT INTO "Examination" VALUES ("1991-10-15", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-25", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-01", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-30", "Normal");
INSERT INTO "Examination" VALUES ("1991-10-03", "Elevated T-BIL");