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

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

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



INSERT INTO "Examination" VALUES ("2023-01-15", "100", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-02-20", "50", "Healthy");
INSERT INTO "Examination" VALUES ("2023-03-10", "200", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-04-05", "75", "Healthy");
INSERT INTO "Examination" VALUES ("2023-05-12", "120", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-06-01", "60", "Healthy");
INSERT INTO "Examination" VALUES ("2023-07-08", "180", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-08-22", "90", "Healthy");
INSERT INTO "Examination" VALUES ("2023-09-19", "150", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-10-25", "40", "Healthy");
INSERT INTO "Patient" VALUES ("1", "1982-03-10");
INSERT INTO "Patient" VALUES ("2", "1982-07-25");
INSERT INTO "Patient" VALUES ("3", "1983-01-01");
INSERT INTO "Patient" VALUES ("4", "1982-11-15");
INSERT INTO "Patient" VALUES ("5", "1981-05-20");
INSERT INTO "Patient" VALUES ("6", "1982-09-01");
INSERT INTO "Patient" VALUES ("7", "1984-02-28");
INSERT INTO "Patient" VALUES ("8", "1982-04-18");
INSERT INTO "Patient" VALUES ("9", "1980-12-05");
INSERT INTO "Patient" VALUES ("10", "1982-06-30");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "4.2");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-15", "3.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-15", "5.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-03-01", "5.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-15", "3.8");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-15", "3.5");
INSERT INTO "Laboratory" VALUES ("4", "2023-02-01", "3.4");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-15", "5.5");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-15", "4.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-02-10", "6.0");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-15", "3.2");
INSERT INTO "Laboratory" VALUES ("8", "2023-01-15", "4.5");
INSERT INTO "Laboratory" VALUES ("9", "2023-01-15", "5.2");
INSERT INTO "Laboratory" VALUES ("10", "2023-01-15", "3.6");
INSERT INTO "Laboratory" VALUES ("10", "2023-02-20", "3.5");