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" (
"Diagnosis" TEXT
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"GPT" INT,
"T-BIL" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

CREATE TABLE "Patient" (
"ID" INT UNIQUE,
"SEX" TEXT,
"Admission" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "-");
INSERT INTO "Patient" VALUES ("2", "F", "-");
INSERT INTO "Patient" VALUES ("3", "M", "hospitalized");
INSERT INTO "Patient" VALUES ("4", "F", "-");
INSERT INTO "Patient" VALUES ("5", "M", "emergency");
INSERT INTO "Patient" VALUES ("6", "F", "-");
INSERT INTO "Patient" VALUES ("7", "M", "-");
INSERT INTO "Laboratory" VALUES ("1", "1991-10-05", "45", "1.5");
INSERT INTO "Laboratory" VALUES ("1", "1991-09-30", "50", "1.8");
INSERT INTO "Laboratory" VALUES ("2", "1991-10-15", "60", "2.1");
INSERT INTO "Laboratory" VALUES ("3", "1991-10-20", "55", "1.9");
INSERT INTO "Laboratory" VALUES ("4", "1991-10-10", "40", "1.0");
INSERT INTO "Laboratory" VALUES ("4", "1991-11-01", "42", "1.7");
INSERT INTO "Laboratory" VALUES ("5", "1991-10-25", "48", "1.3");
INSERT INTO "Laboratory" VALUES ("6", "1991-10-30", "52", "2.5");
INSERT INTO "Laboratory" VALUES ("7", "1991-10-12", "47", "1.9");
INSERT INTO "Laboratory" VALUES ("7", "1991-09-15", "49", "1.6");