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

CREATE TABLE "Laboratory" (
"ID" INT,
"Date" DATE,
"TP" FLOAT,
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 "Examination" VALUES ("2023-01-15", "Normal");
INSERT INTO "Examination" VALUES ("2023-02-20", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-03-10", "Normal");
INSERT INTO "Examination" VALUES ("2023-04-05", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-05-12", "Normal");
INSERT INTO "Examination" VALUES ("2023-06-01", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-07-08", "Normal");
INSERT INTO "Examination" VALUES ("2023-08-19", "Thrombosis");
INSERT INTO "Examination" VALUES ("2023-09-25", "Normal");
INSERT INTO "Examination" VALUES ("2023-10-30", "Thrombosis");
INSERT INTO "Patient" VALUES ("1", "F", "1990-05-10");
INSERT INTO "Patient" VALUES ("2", "M", "1985-11-22");
INSERT INTO "Patient" VALUES ("3", "F", "1992-03-15");
INSERT INTO "Patient" VALUES ("4", "M", "1978-08-01");
INSERT INTO "Patient" VALUES ("5", "F", "1995-01-20");
INSERT INTO "Patient" VALUES ("6", "M", "1980-06-30");
INSERT INTO "Patient" VALUES ("7", "F", "1998-09-05");
INSERT INTO "Patient" VALUES ("8", "M", "1975-04-12");
INSERT INTO "Patient" VALUES ("9", "F", "1993-07-18");
INSERT INTO "Patient" VALUES ("10", "M", "1988-02-28");
INSERT INTO "Laboratory" VALUES ("1", "2023-01-16", "5.5");
INSERT INTO "Laboratory" VALUES ("1", "2023-02-16", "6.8");
INSERT INTO "Laboratory" VALUES ("2", "2023-01-17", "7.2");
INSERT INTO "Laboratory" VALUES ("3", "2023-03-11", "9.0");
INSERT INTO "Laboratory" VALUES ("3", "2023-04-11", "6.5");
INSERT INTO "Laboratory" VALUES ("4", "2023-04-06", "7.5");
INSERT INTO "Laboratory" VALUES ("5", "2023-05-13", "5.9");
INSERT INTO "Laboratory" VALUES ("5", "2023-06-13", "8.0");
INSERT INTO "Laboratory" VALUES ("6", "2023-06-02", "6.2");
INSERT INTO "Laboratory" VALUES ("7", "2023-07-09", "8.8");
INSERT INTO "Laboratory" VALUES ("7", "2023-08-09", "7.0");
INSERT INTO "Laboratory" VALUES ("8", "2023-08-20", "7.1");
INSERT INTO "Laboratory" VALUES ("9", "2023-09-26", "5.0");
INSERT INTO "Laboratory" VALUES ("9", "2023-10-26", "6.0");
INSERT INTO "Laboratory" VALUES ("10", "2023-10-31", "7.8");