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,
"Document_Name" VARCHAR(255),
PRIMARY KEY ("Document_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 "Documents" VALUES ("1", "User Guide");
INSERT INTO "Documents" VALUES ("2", "Project Plan");
INSERT INTO "Documents" VALUES ("3", "Annual Report");
INSERT INTO "Documents" VALUES ("4", "Book Summary");
INSERT INTO "Documents" VALUES ("5", "Research Paper");
INSERT INTO "Ref_Template_Types" VALUES ("TPL001", "Invoice");
INSERT INTO "Ref_Template_Types" VALUES ("TPL002", "Book");
INSERT INTO "Ref_Template_Types" VALUES ("TPL003", "Letter");
INSERT INTO "Ref_Template_Types" VALUES ("TPL004", "Memo");
INSERT INTO "Ref_Template_Types" VALUES ("TPL005", "Report");
INSERT INTO "Templates" VALUES ("101", "TPL001", "Standard invoice template");
INSERT INTO "Templates" VALUES ("102", "TPL002", "Book template with chapters");
INSERT INTO "Templates" VALUES ("103", "TPL003", "Formal letter template");
INSERT INTO "Templates" VALUES ("104", "TPL004", "Internal memo template");
INSERT INTO "Templates" VALUES ("105", "TPL005", "Annual report template");
INSERT INTO "Templates" VALUES ("106", "TPL002", "Book template with index");
INSERT INTO "Templates" VALUES ("107", "TPL003", "Informal letter template");