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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"IGG" INT,
PRIMARY KEY ("ID", "Date")
);

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



INSERT INTO "Patient" VALUES ("1", "F", "1982-05-14", "Thrombosis");
INSERT INTO "Patient" VALUES ("2", "M", "1985-11-23", "No Thrombosis");
INSERT INTO "Patient" VALUES ("3", "F", "1987-07-30", "Thrombosis");
INSERT INTO "Patient" VALUES ("4", "F", "1979-12-01", "No Thrombosis");
INSERT INTO "Patient" VALUES ("5", "F", "1983-03-22", "Thrombosis");
INSERT INTO "Patient" VALUES ("6", "M", "1981-08-15", "Thrombosis");
INSERT INTO "Patient" VALUES ("7", "F", "1990-01-10", "No Thrombosis");
INSERT INTO "Patient" VALUES ("8", "F", "1984-09-05", "Thrombosis");
INSERT INTO "Patient" VALUES ("9", "M", "1988-06-17", "No Thrombosis");
INSERT INTO "Patient" VALUES ("10", "F", "1986-04-28", "Thrombosis");
INSERT INTO "Examination" VALUES ("1", "120", "N");
INSERT INTO "Examination" VALUES ("2", "80", "P");
INSERT INTO "Examination" VALUES ("3", "150", "N");
INSERT INTO "Examination" VALUES ("4", "90", "N");
INSERT INTO "Examination" VALUES ("5", "110", "N");
INSERT INTO "Examination" VALUES ("6", "130", "P");
INSERT INTO "Examination" VALUES ("7", "100", "N");
INSERT INTO "Examination" VALUES ("8", "140", "N");
INSERT INTO "Examination" VALUES ("9", "85", "P");
INSERT INTO "Examination" VALUES ("10", "125", "N");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-15", "200");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-15", "210");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-20", "180");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-10", "220");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-25", "190");
INSERT INTO "Laboratory" VALUES ("5", "2023-02-05", "205");
INSERT INTO "Laboratory" VALUES ("6", "2023-03-15", "195");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-30", "185");
INSERT INTO "Laboratory" VALUES ("8", "2023-02-20", "215");
INSERT INTO "Laboratory" VALUES ("9", "2023-03-25", "175");
INSERT INTO "Laboratory" VALUES ("10", "2023-01-10", "225");