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" (
"KCT" TEXT,
"RVVT" TEXT,
"LAC" TEXT
);

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

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



INSERT INTO "Patient" VALUES ("1", "1979-12-31");
INSERT INTO "Patient" VALUES ("2", "1980-01-02");
INSERT INTO "Patient" VALUES ("3", "1990-05-15");
INSERT INTO "Patient" VALUES ("4", "1985-07-20");
INSERT INTO "Patient" VALUES ("5", "1980-01-01");
INSERT INTO "Patient" VALUES ("6", "2000-12-12");
INSERT INTO "Patient" VALUES ("7", "1975-03-10");
INSERT INTO "Patient" VALUES ("8", "1982-11-30");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-01", "200.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-02", "100.0");
INSERT INTO "Laboratory" VALUES ("2", "2023-06-01", "160.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-01-03", "500.0");
INSERT INTO "Laboratory" VALUES ("4", "2023-01-04", "149.9");
INSERT INTO "Laboratory" VALUES ("4", "2023-07-01", "451.0");
INSERT INTO "Laboratory" VALUES ("5", "2023-01-05", "300.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-01-06", "149.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-08-01", "460.0");
INSERT INTO "Laboratory" VALUES ("7", "2023-01-07", "200.0");
INSERT INTO "Laboratory" VALUES ("8", "2023-01-08", "100.0");
INSERT INTO "Laboratory" VALUES ("8", "2023-09-01", "500.0");
INSERT INTO "Examination" VALUES ("normal", "normal", "normal");
INSERT INTO "Examination" VALUES ("abnormal", "normal", "normal");
INSERT INTO "Examination" VALUES ("normal", "abnormal", "normal");
INSERT INTO "Examination" VALUES ("normal", "normal", "abnormal");
INSERT INTO "Examination" VALUES ("abnormal", "abnormal", "abnormal");
INSERT INTO "Examination" VALUES ("normal", "normal", "normal");
INSERT INTO "Examination" VALUES ("abnormal", "normal", "abnormal");
INSERT INTO "Examination" VALUES ("normal", "abnormal", "normal");