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

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,
"Diagnosis" TEXT,
PRIMARY KEY ("ID")
);



INSERT INTO "Patient" VALUES ("1", "M", "Thrombosis");
INSERT INTO "Patient" VALUES ("2", "F", "No thrombosis");
INSERT INTO "Patient" VALUES ("3", "M", "Thrombosis");
INSERT INTO "Patient" VALUES ("4", "F", "No thrombosis");
INSERT INTO "Patient" VALUES ("5", "M", "Thrombosis");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "7.2", "3.4");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-15", "7.0", "3.6");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-12", "6.8", "3.5");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "7.5", "3.2");
INSERT INTO "Laboratory" VALUES ("3", "2024-03-01", "7.3", "3.1");
INSERT INTO "Laboratory" VALUES ("4", "2024-02-10", "6.9", "3.7");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-25", "7.1", "3.0");
INSERT INTO "Laboratory" VALUES ("5", "2024-02-28", "7.0", "3.4");
INSERT INTO "Examination" VALUES ("100", "Thrombosis");
INSERT INTO "Examination" VALUES ("200", "No thrombosis");
INSERT INTO "Examination" VALUES ("300", "Thrombosis");
INSERT INTO "Examination" VALUES ("400", "No thrombosis");
INSERT INTO "Examination" VALUES ("500", "Thrombosis");