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" (
"Diagnosis" TEXT
);

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"UN" INT,
"CRE" FLOAT,
PRIMARY KEY ("ID", "Date"),
FOREIGN KEY ("ID") REFERENCES "Patient"("ID")
);

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



INSERT INTO "Examination" VALUES ("RA");
INSERT INTO "Examination" VALUES ("OA");
INSERT INTO "Examination" VALUES ("Gout");
INSERT INTO "Patient" VALUES ("1", "M", "1980-05-12", "2023-01-10", "RA");
INSERT INTO "Patient" VALUES ("2", "F", "1975-11-23", "2023-02-15", "OA");
INSERT INTO "Patient" VALUES ("3", "F", "1990-07-30", "2023-03-05", "RA");
INSERT INTO "Patient" VALUES ("4", "M", "1965-12-01", "2023-01-20", "Gout");
INSERT INTO "Patient" VALUES ("5", "F", "1988-09-14", "2023-02-28", "RA");
INSERT INTO "Patient" VALUES ("6", "M", "1972-04-18", "2023-03-10", "RA");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-11", "25", "0.9");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-12", "35", "1.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-02-16", "28", "1.1");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-06", "29", "0.8");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-07", "31", "0.9");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-21", "20", "1.2");
INSERT INTO "Laboratory" VALUES ("5", "2023-03-01", "30", "1.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-03-02", "27", "1.1");
INSERT INTO "Laboratory" VALUES ("6", "2023-03-11", "40", "1.3");
INSERT INTO "Laboratory" VALUES ("6", "2023-03-12", "29", "1.2");