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

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



INSERT INTO "Patient" VALUES ("1", "F", "1980-05-10", "SLE");
INSERT INTO "Patient" VALUES ("2", "M", "1975-11-22", "Hypertension");
INSERT INTO "Patient" VALUES ("3", "F", "1990-03-15", "SLE");
INSERT INTO "Patient" VALUES ("4", "M", "1960-01-01", "Diabetes");
INSERT INTO "Patient" VALUES ("5", "F", "1985-07-30", "SLE");
INSERT INTO "Patient" VALUES ("6", "M", "1970-09-12", "SLE");
INSERT INTO "Patient" VALUES ("7", "F", "1965-02-28", "SLE");
INSERT INTO "Patient" VALUES ("8", "M", "1995-04-05", "Asthma");
INSERT INTO "Patient" VALUES ("9", "F", "1955-12-25", "SLE");
INSERT INTO "Patient" VALUES ("10", "M", "1982-06-18", "SLE");
INSERT INTO "Examination" VALUES ("1", "2023-01-15", "SLE");
INSERT INTO "Examination" VALUES ("2", "2023-02-01", "Hypertension");
INSERT INTO "Examination" VALUES ("3", "2023-03-10", "SLE");
INSERT INTO "Examination" VALUES ("4", "2023-04-05", "Diabetes");
INSERT INTO "Examination" VALUES ("5", "2023-05-20", "SLE");
INSERT INTO "Examination" VALUES ("6", "2023-06-10", "SLE");
INSERT INTO "Examination" VALUES ("7", "2023-07-01", "SLE");
INSERT INTO "Examination" VALUES ("8", "2023-08-15", "Asthma");
INSERT INTO "Examination" VALUES ("9", "2023-09-01", "SLE");
INSERT INTO "Examination" VALUES ("10", "2023-10-20", "SLE");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-16", "4.5", "12.5");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-16", "4.2", "9.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-11", "4.8", "11.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-04-11", "4.7", "17.1");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-21", "4.0", "10.5");
INSERT INTO "Laboratory" VALUES ("6", "2023-06-11", "5.0", "16.0");
INSERT INTO "Laboratory" VALUES ("7", "2023-07-02", "4.9", "13.2");
INSERT INTO "Laboratory" VALUES ("7", "2023-08-02", "4.9", "9.9");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-02", "4.6", "11.8");
INSERT INTO "Laboratory" VALUES ("9", "2023-10-02", "4.6", "10.0");
INSERT INTO "Laboratory" VALUES ("10", "2023-10-21", "4.3", "15.5");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-02", "5.1", "14.0");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-06", "4.4", "12.0");
INSERT INTO "Laboratory" VALUES ("8", "2023-08-16", "4.7", "13.5");