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,
"Thrombosis" INT
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"TP" FLOAT,
"ALB" FLOAT,
"PLT" INT,
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", "F", "SLE");
INSERT INTO "Patient" VALUES ("2", "M", "SLE");
INSERT INTO "Patient" VALUES ("3", "F", "RA");
INSERT INTO "Patient" VALUES ("4", "F", "SLE");
INSERT INTO "Patient" VALUES ("5", "F", "SLE");
INSERT INTO "Patient" VALUES ("6", "M", "RA");
INSERT INTO "Patient" VALUES ("7", "F", "SLE");
INSERT INTO "Patient" VALUES ("8", "F", "OA");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-01", "12.5", "3.8", "450");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-01", "13.0", "4.0", "420");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-15", "11.0", "3.5", "410");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "10.5", "3.2", "390");
INSERT INTO "Laboratory" VALUES ("4", "2024-03-01", "12.0", "3.9", "401");
INSERT INTO "Laboratory" VALUES ("5", "2024-02-10", "11.5", "3.7", "399");
INSERT INTO "Laboratory" VALUES ("5", "2024-03-10", "11.8", "3.6", "405");
INSERT INTO "Laboratory" VALUES ("6", "2024-01-05", "10.0", "3.1", "430");
INSERT INTO "Laboratory" VALUES ("7", "2024-04-01", "12.2", "4.1", "500");
INSERT INTO "Laboratory" VALUES ("7", "2024-05-01", "12.4", "4.2", "480");
INSERT INTO "Laboratory" VALUES ("8", "2024-01-10", "11.3", "3.4", "410");
INSERT INTO "Examination" VALUES ("SLE", "1");
INSERT INTO "Examination" VALUES ("RA", "0");
INSERT INTO "Examination" VALUES ("OA", "0");