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 "Documents" (
"Document_ID" INT,
"Template_ID" INT,
PRIMARY KEY ("Document_ID"),
FOREIGN KEY ("Template_ID") REFERENCES "Templates"("Template_ID")
);

CREATE TABLE "Ref_Template_Types" (
"Template_Type_Code" CHAR(15) UNIQUE,
"Template_Type_Description" VARCHAR(255),
PRIMARY KEY ("Template_Type_Code")
);

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Ref_Template_Types" VALUES ("FORM", "Standard Form Template");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Reporting Template");
INSERT INTO "Ref_Template_Types" VALUES ("LETTER", "Official Letter Template");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Internal Memorandum Template");
INSERT INTO "Ref_Template_Types" VALUES ("AGREEMENT", "Legal Agreement Template");
INSERT INTO "Templates" VALUES ("101", "Invoice Template v1.0");
INSERT INTO "Templates" VALUES ("102", "Purchase Order Template v2.1");
INSERT INTO "Templates" VALUES ("103", "Meeting Minutes Template");
INSERT INTO "Templates" VALUES ("104", "Employee Handbook Template");
INSERT INTO "Templates" VALUES ("105", "Contract Template A");
INSERT INTO "Templates" VALUES ("106", "Contract Template B");
INSERT INTO "Templates" VALUES ("107", "Unused Template X");
INSERT INTO "Templates" VALUES ("108", "Unused Template Y");
INSERT INTO "Templates" VALUES ("109", "Unused Template Z");
INSERT INTO "Documents" VALUES ("1", "101");
INSERT INTO "Documents" VALUES ("2", "102");
INSERT INTO "Documents" VALUES ("3", "101");
INSERT INTO "Documents" VALUES ("4", "103");
INSERT INTO "Documents" VALUES ("5", "105");
INSERT INTO "Documents" VALUES ("6", "102");
INSERT INTO "Documents" VALUES ("7", "105");
INSERT INTO "Documents" VALUES ("8", "101");
INSERT INTO "Documents" VALUES ("9", "103");
INSERT INTO "Documents" VALUES ("10", "106");