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,
"Version_Number" 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 ("PRES", "Presentation");
INSERT INTO "Ref_Template_Types" VALUES ("DOC", "Document");
INSERT INTO "Ref_Template_Types" VALUES ("RPT", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("FORM", "Form");
INSERT INTO "Ref_Template_Types" VALUES ("EMAIL", "Email Template");
INSERT INTO "Templates" VALUES ("101", "1", "PRES", "Sales Pitch Template");
INSERT INTO "Templates" VALUES ("102", "2", "DOC", "Meeting Minutes Template");
INSERT INTO "Templates" VALUES ("103", "1", "RPT", "Quarterly Financial Report");
INSERT INTO "Templates" VALUES ("104", "3", "PRES", "Project Proposal Presentation");
INSERT INTO "Templates" VALUES ("105", "1", "FORM", "Customer Feedback Form");
INSERT INTO "Templates" VALUES ("106", "1", "DOC", "Technical Specification");
INSERT INTO "Templates" VALUES ("107", "2", "PRES", "Marketing Strategy Presentation");
INSERT INTO "Templates" VALUES ("108", "1", "EMAIL", "Welcome Email");
INSERT INTO "Templates" VALUES ("109", "1", "PRES", "Training Module Presentation");
INSERT INTO "Templates" VALUES ("110", "1", "DOC", "User Manual");
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", "101");
INSERT INTO "Documents" VALUES ("7", "107");
INSERT INTO "Documents" VALUES ("8", "109");
INSERT INTO "Documents" VALUES ("9", "102");
INSERT INTO "Documents" VALUES ("10", "106");