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,
"GOT" INT,
"GPT" 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", "M", "SLE");
INSERT INTO "Patient" VALUES ("2", "F", "No SLE");
INSERT INTO "Patient" VALUES ("3", "F", "SLE");
INSERT INTO "Patient" VALUES ("4", "M", "No SLE");
INSERT INTO "Patient" VALUES ("5", "F", "SLE");
INSERT INTO "Patient" VALUES ("6", "M", "No SLE");
INSERT INTO "Patient" VALUES ("7", "F", "No SLE");
INSERT INTO "Patient" VALUES ("8", "M", "SLE");
INSERT INTO "Patient" VALUES ("9", "F", "No SLE");
INSERT INTO "Patient" VALUES ("10", "M", "SLE");
INSERT INTO "Examination" VALUES ("1", "2023-01-10", "SLE");
INSERT INTO "Examination" VALUES ("2", "2023-01-15", "No SLE");
INSERT INTO "Examination" VALUES ("3", "2023-02-20", "SLE");
INSERT INTO "Examination" VALUES ("4", "2023-03-05", "No SLE");
INSERT INTO "Examination" VALUES ("5", "2023-03-10", "SLE");
INSERT INTO "Examination" VALUES ("6", "2023-04-01", "No SLE");
INSERT INTO "Examination" VALUES ("7", "2023-04-15", "No SLE");
INSERT INTO "Examination" VALUES ("8", "2023-05-01", "SLE");
INSERT INTO "Examination" VALUES ("9", "2023-05-10", "No SLE");
INSERT INTO "Examination" VALUES ("10", "2023-06-01", "SLE");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-10", "65", "30");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-15", "55", "25");
INSERT INTO "Laboratory" VALUES ("3", "2023-02-20", "70", "40");
INSERT INTO "Laboratory" VALUES ("4", "2023-03-05", "45", "20");
INSERT INTO "Laboratory" VALUES ("5", "2023-03-10", "60", "35");
INSERT INTO "Laboratory" VALUES ("6", "2023-04-01", "62", "28");
INSERT INTO "Laboratory" VALUES ("7", "2023-04-15", "59", "22");
INSERT INTO "Laboratory" VALUES ("8", "2023-05-01", "80", "50");
INSERT INTO "Laboratory" VALUES ("9", "2023-05-10", "58", "30");
INSERT INTO "Laboratory" VALUES ("10", "2023-06-01", "61", "33");