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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"SM" TEXT,
"SSA" TEXT,
"DNA" TEXT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "Lupus");
INSERT INTO "Patient" VALUES ("2", "Rheumatoid Arthritis");
INSERT INTO "Patient" VALUES ("3", "Sjögren's Syndrome");
INSERT INTO "Patient" VALUES ("4", "Mixed Connective Tissue Disease");
INSERT INTO "Patient" VALUES ("5", "Healthy");
INSERT INTO "Examination" VALUES ("1", "5", "Lupus");
INSERT INTO "Examination" VALUES ("2", "7", "Rheumatoid Arthritis");
INSERT INTO "Examination" VALUES ("3", "3", "Sjögren's Syndrome");
INSERT INTO "Examination" VALUES ("4", "6", "Mixed Connective Tissue Disease");
INSERT INTO "Examination" VALUES ("5", "4", "Healthy");
INSERT INTO "Laboratory" VALUES ("1", "2024-01-10", "Normal", "Normal", "9");
INSERT INTO "Laboratory" VALUES ("1", "2024-02-15", "Normal", "Normal", "7");
INSERT INTO "Laboratory" VALUES ("2", "2024-01-12", "Normal", "Elevated", "8");
INSERT INTO "Laboratory" VALUES ("3", "2024-01-20", "Elevated", "Normal", "5");
INSERT INTO "Laboratory" VALUES ("4", "2024-01-25", "Normal", "Normal", "10");
INSERT INTO "Laboratory" VALUES ("5", "2024-01-30", "Normal", "Normal", "2");