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" (
"ANA" INT
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"RBC" FLOAT,
"HGB" FLOAT,
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-20", "2024-04-01", "Anemia");
INSERT INTO "Patient" VALUES ("2", "F", "1990-11-15", "2024-04-02", "Iron Deficiency");
INSERT INTO "Patient" VALUES ("3", "M", "1975-07-30", "2024-04-03", "Healthy");
INSERT INTO "Patient" VALUES ("4", "F", "2000-01-10", "2024-04-04", "Thalassemia");
INSERT INTO "Patient" VALUES ("5", "M", "1965-12-05", "2024-04-05", "Polycythemia");
INSERT INTO "Laboratory" VALUES ("1", "2024-04-01", "3.2", "12.5");
INSERT INTO "Laboratory" VALUES ("2", "2024-04-02", "3.4", "11.8");
INSERT INTO "Laboratory" VALUES ("3", "2024-04-03", "4.5", "15.0");
INSERT INTO "Laboratory" VALUES ("4", "2024-04-04", "3.0", "13.2");
INSERT INTO "Laboratory" VALUES ("5", "2024-04-05", "5.0", "17.0");
INSERT INTO "Examination" VALUES ("1");
INSERT INTO "Examination" VALUES ("0");
INSERT INTO "Examination" VALUES ("1");
INSERT INTO "Examination" VALUES ("0");
INSERT INTO "Examination" VALUES ("1");