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

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



INSERT INTO "Patient" VALUES ("1", "M");
INSERT INTO "Patient" VALUES ("2", "F");
INSERT INTO "Patient" VALUES ("3", "M");
INSERT INTO "Patient" VALUES ("4", "F");
INSERT INTO "Patient" VALUES ("5", "M");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "7.2", "3.5");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-15", "7.0", "4.9");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-12", "6.8", "5.5");
INSERT INTO "Laboratory" VALUES ("2", "2024-02-20", "7.1", "5.4");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-11", "7.3", "3.6");
INSERT INTO "Laboratory" VALUES ("3", "2024-02-18", "7.4", "5.3");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-09", "6.9", "3.4");
INSERT INTO "Laboratory" VALUES ("4", "2024-02-22", "7.0", "4.8");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-13", "7.5", "5.2");
INSERT INTO "Laboratory" VALUES ("5", "2024-02-25", "7.6", "5.0");
INSERT INTO "Examination" VALUES ("1", "2024-01-10", "120");
INSERT INTO "Examination" VALUES ("1", "2024-02-15", "115");
INSERT INTO "Examination" VALUES ("2", "2024-01-12", "130");
INSERT INTO "Examination" VALUES ("2", "2024-02-20", "125");
INSERT INTO "Examination" VALUES ("3", "2024-01-11", "110");
INSERT INTO "Examination" VALUES ("3", "2024-02-18", "112");
INSERT INTO "Examination" VALUES ("4", "2024-01-09", "118");
INSERT INTO "Examination" VALUES ("4", "2024-02-22", "119");
INSERT INTO "Examination" VALUES ("5", "2024-01-13", "121");
INSERT INTO "Examination" VALUES ("5", "2024-02-25", "123");