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),
"Document_Description" 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,
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 ("FORM");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT");
INSERT INTO "Ref_Template_Types" VALUES ("LETTER");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO");
INSERT INTO "Ref_Template_Types" VALUES ("CONTRACT");
INSERT INTO "Ref_Template_Types" VALUES ("AGREEMENT");
INSERT INTO "Templates" VALUES ("101", "FORM", "Standard Application Form");
INSERT INTO "Templates" VALUES ("102", "REPORT", "Monthly Sales Report");
INSERT INTO "Templates" VALUES ("103", "LETTER", "Customer Welcome Letter");
INSERT INTO "Templates" VALUES ("104", "FORM", "Employee Onboarding Form");
INSERT INTO "Templates" VALUES ("105", "REPORT", "Quarterly Financial Report");
INSERT INTO "Templates" VALUES ("106", "MEMO", "Internal Meeting Memo");
INSERT INTO "Templates" VALUES ("107", "CONTRACT", "Service Agreement Template");
INSERT INTO "Templates" VALUES ("108", "AGREEMENT", "Non-Disclosure Agreement");
INSERT INTO "Templates" VALUES ("109", "LETTER", "Termination Letter Template");
INSERT INTO "Templates" VALUES ("110", "FORM", "Feedback Survey Form");
INSERT INTO "Documents" VALUES ("1", "101", "Application_001", "Application for Job Position A");
INSERT INTO "Documents" VALUES ("2", "102", "Sales_Report_Jan", "Sales performance for January");
INSERT INTO "Documents" VALUES ("3", "103", "Welcome_Letter_Cust_A", "Welcome letter for new customer A");
INSERT INTO "Documents" VALUES ("4", "104", "Onboarding_Emp_001", "Onboarding documents for employee 001");
INSERT INTO "Documents" VALUES ("5", "101", "Application_002", "Application for Job Position B");
INSERT INTO "Documents" VALUES ("6", "102", "Sales_Report_Feb", "Sales performance for February");
INSERT INTO "Documents" VALUES ("7", "103", "Welcome_Letter_Cust_B", "Welcome letter for new customer B");
INSERT INTO "Documents" VALUES ("8", "104", "Onboarding_Emp_002", "Onboarding documents for employee 002");
INSERT INTO "Documents" VALUES ("9", "105", "Q1_Financial_Report", "Financial report for Q1");