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,
"Template_Type_Code" CHAR(15),
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID"),
FOREIGN KEY ("Template_Type_Code") REFERENCES "Ref_Template_Types"("Template_Type_Code")
);





INSERT INTO "Ref_Template_Types" VALUES ("AD", "Administrative Document");
INSERT INTO "Ref_Template_Types" VALUES ("FN", "Financial Document");
INSERT INTO "Ref_Template_Types" VALUES ("HR", "Human Resources Document");
INSERT INTO "Ref_Template_Types" VALUES ("MK", "Marketing Material");
INSERT INTO "Ref_Template_Types" VALUES ("LG", "Legal Agreement");
INSERT INTO "Ref_Template_Types" VALUES ("IT", "IT Policy Document");
INSERT INTO "Ref_Template_Types" VALUES ("PR", "Project Report");
INSERT INTO "Ref_Template_Types" VALUES ("SC", "Sales Contract");
INSERT INTO "Templates" VALUES ("101", "AD", "Meeting Minutes Template");
INSERT INTO "Templates" VALUES ("102", "FN", "Invoice Template");
INSERT INTO "Templates" VALUES ("103", "HR", "Employee Handbook Template");
INSERT INTO "Templates" VALUES ("104", "MK", "Brochure Template");
INSERT INTO "Templates" VALUES ("105", "LG", "Non-Disclosure Agreement Template");
INSERT INTO "Templates" VALUES ("106", "AD", "Memo Template");
INSERT INTO "Templates" VALUES ("107", "FN", "Expense Report Template");
INSERT INTO "Templates" VALUES ("108", "IT", "Security Policy Template");
INSERT INTO "Templates" VALUES ("109", "PR", "Project Plan Template");
INSERT INTO "Templates" VALUES ("110", "SC", "Service Agreement Template");
INSERT INTO "Templates" VALUES ("111", "HR", "Offer Letter Template");
INSERT INTO "Documents" VALUES ("1", "101");
INSERT INTO "Documents" VALUES ("2", "102");
INSERT INTO "Documents" VALUES ("3", "103");
INSERT INTO "Documents" VALUES ("4", "104");
INSERT INTO "Documents" VALUES ("5", "105");
INSERT INTO "Documents" VALUES ("6", "106");
INSERT INTO "Documents" VALUES ("7", "107");
INSERT INTO "Documents" VALUES ("8", "108");
INSERT INTO "Documents" VALUES ("9", "109");
INSERT INTO "Documents" VALUES ("10", "110");
INSERT INTO "Documents" VALUES ("11", "101");
INSERT INTO "Documents" VALUES ("12", "106");
INSERT INTO "Documents" VALUES ("13", "111");