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,
"Document_Name" VARCHAR(255),
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_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 ("CV", "Curriculum Vitae");
INSERT INTO "Ref_Template_Types" VALUES ("LTR", "Letter");
INSERT INTO "Ref_Template_Types" VALUES ("RPT", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Memorandum");
INSERT INTO "Ref_Template_Types" VALUES ("INV", "Invoice");
INSERT INTO "Templates" VALUES ("1", "CV", "Basic CV template with contact info and experience sections");
INSERT INTO "Templates" VALUES ("2", "CV", "Advanced CV template with skills and projects sections");
INSERT INTO "Templates" VALUES ("3", "LTR", "Formal letter template for business correspondence");
INSERT INTO "Templates" VALUES ("4", "RPT", "Monthly sales report template");
INSERT INTO "Templates" VALUES ("5", "CV", "Creative CV template with portfolio section");
INSERT INTO "Templates" VALUES ("6", "MEMO", "Internal memo template");
INSERT INTO "Templates" VALUES ("7", "INV", "Standard invoice template");
INSERT INTO "Templates" VALUES ("8", "CV", "Minimalist CV template");
INSERT INTO "Templates" VALUES ("9", "LTR", "Informal letter template");
INSERT INTO "Templates" VALUES ("10", "RPT", "Annual financial report template");
INSERT INTO "Documents" VALUES ("101", "1", "John Doe CV");
INSERT INTO "Documents" VALUES ("102", "2", "Jane Smith CV");
INSERT INTO "Documents" VALUES ("103", "3", "Business Proposal Letter");
INSERT INTO "Documents" VALUES ("104", "5", "Portfolio CV for Alice");
INSERT INTO "Documents" VALUES ("105", "6", "Team Meeting Memo");
INSERT INTO "Documents" VALUES ("106", "8", "Minimalist CV for Bob");
INSERT INTO "Documents" VALUES ("107", "4", "March Sales Report");
INSERT INTO "Documents" VALUES ("108", "7", "Invoice #12345");
INSERT INTO "Documents" VALUES ("109", "9", "Friendly Letter to Client");
INSERT INTO "Documents" VALUES ("110", "10", "Annual Financial Report 2023");