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 ("Book", "Book");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Memorandum");
INSERT INTO "Ref_Template_Types" VALUES ("LETTER", "Letter");
INSERT INTO "Ref_Template_Types" VALUES ("FORM", "Form");
INSERT INTO "Ref_Template_Types" VALUES ("AGREEMENT", "Agreement");
INSERT INTO "Ref_Template_Types" VALUES ("PRESENTATION", "Presentation");
INSERT INTO "Ref_Template_Types" VALUES ("INVOICE", "Invoice");
INSERT INTO "Templates" VALUES ("1", "Book", "Technical Manual");
INSERT INTO "Templates" VALUES ("2", "REPORT", "Annual Financial Report");
INSERT INTO "Templates" VALUES ("3", "MEMO", "Internal Communication Memo");
INSERT INTO "Templates" VALUES ("4", "LETTER", "Client Correspondence");
INSERT INTO "Templates" VALUES ("5", "FORM", "Expense Claim Form");
INSERT INTO "Templates" VALUES ("6", "Book", "Fiction Novel");
INSERT INTO "Templates" VALUES ("7", "REPORT", "Project Status Report");
INSERT INTO "Templates" VALUES ("8", "AGREEMENT", "Service Level Agreement");
INSERT INTO "Templates" VALUES ("9", "PRESENTATION", "Sales Pitch Deck");
INSERT INTO "Templates" VALUES ("10", "INVOICE", "Customer Billing Invoice");
INSERT INTO "Templates" VALUES ("11", "Book", "Cookbook");
INSERT INTO "Templates" VALUES ("12", "LETTER", "Job Application Letter");
INSERT INTO "Documents" VALUES ("101", "1");
INSERT INTO "Documents" VALUES ("102", "2");
INSERT INTO "Documents" VALUES ("103", "3");
INSERT INTO "Documents" VALUES ("104", "4");
INSERT INTO "Documents" VALUES ("105", "5");
INSERT INTO "Documents" VALUES ("106", "6");
INSERT INTO "Documents" VALUES ("107", "7");
INSERT INTO "Documents" VALUES ("108", "8");
INSERT INTO "Documents" VALUES ("109", "9");
INSERT INTO "Documents" VALUES ("110", "10");
INSERT INTO "Documents" VALUES ("111", "1");
INSERT INTO "Documents" VALUES ("112", "6");
INSERT INTO "Documents" VALUES ("113", "11");
INSERT INTO "Documents" VALUES ("114", "12");