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

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



INSERT INTO "Patient" VALUES ("1", "M", "1980-05-12", "-", "Thrombosis");
INSERT INTO "Patient" VALUES ("2", "F", "1975-11-30", "-", "Healthy");
INSERT INTO "Patient" VALUES ("3", "M", "1990-07-22", "Hospital", "Fracture");
INSERT INTO "Patient" VALUES ("4", "F", "1985-03-15", "-", "Thrombosis");
INSERT INTO "Patient" VALUES ("5", "M", "2000-01-01", "-", "Healthy");
INSERT INTO "Patient" VALUES ("6", "F", "1960-12-10", "Hospital", "Diabetes");
INSERT INTO "Patient" VALUES ("7", "M", "1995-09-09", "-", "Thrombosis");
INSERT INTO "Patient" VALUES ("8", "F", "1988-06-06", "-", "Healthy");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "250");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-10", "310");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-15", "299");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-20", "280");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-25", "150");
INSERT INTO "Laboratory" VALUES ("5", "2023-02-01", "305");
INSERT INTO "Laboratory" VALUES ("5", "2023-02-15", "290");
INSERT INTO "Laboratory" VALUES ("7", "2023-03-01", "299");
INSERT INTO "Laboratory" VALUES ("8", "2023-03-05", "400");
INSERT INTO "Examination" VALUES ("2023-01-10", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-01-15", "Healthy");
INSERT INTO "Examination" VALUES ("2023-01-20", "Fracture");
INSERT INTO "Examination" VALUES ("2023-01-25", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-02-01", "Healthy");
INSERT INTO "Examination" VALUES ("2023-03-01", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-03-05", "Healthy");