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,
"CPK" INT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Patient" VALUES ("1", "M", "1940-05-10");
INSERT INTO "Patient" VALUES ("2", "F", "1950-11-20");
INSERT INTO "Patient" VALUES ("3", "M", "1935-01-15");
INSERT INTO "Patient" VALUES ("4", "M", "1955-07-01");
INSERT INTO "Patient" VALUES ("5", "F", "1960-03-25");
INSERT INTO "Patient" VALUES ("6", "M", "1945-09-12");
INSERT INTO "Patient" VALUES ("7", "M", "1956-12-31");
INSERT INTO "Patient" VALUES ("8", "F", "1936-02-29");
INSERT INTO "Patient" VALUES ("9", "M", "1948-04-04");
INSERT INTO "Patient" VALUES ("10", "M", "1952-08-08");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-01", "300");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-01", "200");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-05", "150");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-10", "280");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-15", "350");
INSERT INTO "Laboratory" VALUES ("4", "2023-02-15", "240");
INSERT INTO "Laboratory" VALUES ("6", "2023-03-01", "260");
INSERT INTO "Laboratory" VALUES ("7", "2023-03-05", "290");
INSERT INTO "Laboratory" VALUES ("9", "2023-03-10", "180");
INSERT INTO "Laboratory" VALUES ("10", "2023-03-15", "310");
INSERT INTO "Laboratory" VALUES ("10", "2023-04-01", "270");
INSERT INTO "Examination" VALUES ("2023-01-01", "10", "Normal");
INSERT INTO "Examination" VALUES ("2023-01-05", "20", "Positive");
INSERT INTO "Examination" VALUES ("2023-01-10", "5", "Normal");
INSERT INTO "Examination" VALUES ("2023-01-15", "15", "Normal");
INSERT INTO "Examination" VALUES ("2023-03-01", "8", "Normal");
INSERT INTO "Examination" VALUES ("2023-03-05", "25", "Positive");
INSERT INTO "Examination" VALUES ("2023-03-10", "12", "Normal");
INSERT INTO "Examination" VALUES ("2023-03-15", "30", "Positive");