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
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"TP" FLOAT,
"ALB" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "M", "1980-05-12", "Healthy");
INSERT INTO "Patient" VALUES ("2", "F", "1975-11-30", "Diabetes");
INSERT INTO "Patient" VALUES ("3", "M", "1990-07-22", "Hypertension");
INSERT INTO "Patient" VALUES ("4", "F", "1985-03-15", "Healthy");
INSERT INTO "Patient" VALUES ("5", "M", "2000-01-01", "Anemia");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "5.8", "4.0");
INSERT INTO "Laboratory" VALUES ("1", "2023-06-15", "6.2", "4.2");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-20", "6.5", "3.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-05", "5.9", "4.1");
INSERT INTO "Laboratory" VALUES ("3", "2023-07-10", "6.1", "4.3");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-12", "6.0", "4.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-18", "5.5", "3.9");
INSERT INTO "Laboratory" VALUES ("5", "2023-08-22", "5.7", "4.1");
INSERT INTO "Examination" VALUES ("2023-01-10");
INSERT INTO "Examination" VALUES ("2023-02-20");
INSERT INTO "Examination" VALUES ("2023-03-05");
INSERT INTO "Examination" VALUES ("2023-04-12");
INSERT INTO "Examination" VALUES ("2023-05-18");
INSERT INTO "Examination" VALUES ("2023-06-15");
INSERT INTO "Examination" VALUES ("2023-07-10");
INSERT INTO "Examination" VALUES ("2023-08-22");