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,
"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 ("INV", "Invoice Template");
INSERT INTO "Ref_Template_Types" VALUES ("ORD", "Order Form Template");
INSERT INTO "Ref_Template_Types" VALUES ("RPT", "Report Template");
INSERT INTO "Ref_Template_Types" VALUES ("LTR", "Letter Template");
INSERT INTO "Ref_Template_Types" VALUES ("MEM", "Memo Template");
INSERT INTO "Ref_Template_Types" VALUES ("AGR", "Agreement Template");
INSERT INTO "Templates" VALUES ("101", "INV", "Standard Invoice Layout");
INSERT INTO "Templates" VALUES ("102", "ORD", "Purchase Order Form");
INSERT INTO "Templates" VALUES ("103", "RPT", "Monthly Sales Report");
INSERT INTO "Templates" VALUES ("104", "LTR", "Formal Business Letter");
INSERT INTO "Templates" VALUES ("105", "INV", "Detailed Invoice with Line Items");
INSERT INTO "Templates" VALUES ("106", "ORD", "Customer Order Form");
INSERT INTO "Templates" VALUES ("107", "RPT", "Quarterly Financial Report");
INSERT INTO "Templates" VALUES ("108", "MEM", "Internal Communication Memo");
INSERT INTO "Templates" VALUES ("109", "AGR", "Service Level Agreement");
INSERT INTO "Templates" VALUES ("110", "LTR", "Informal Correspondence Letter");
INSERT INTO "Documents" VALUES ("1", "101", "Invoice_001", "Invoice for Q1 services");
INSERT INTO "Documents" VALUES ("2", "102", "Order_001", "Order for office supplies");
INSERT INTO "Documents" VALUES ("3", "103", "Sales_Report_Jan", "January sales figures");
INSERT INTO "Documents" VALUES ("4", "104", "Client_Letter_A", "Letter to client A regarding project status");
INSERT INTO "Documents" VALUES ("5", "101", "Invoice_002", "Invoice for Q2 products");
INSERT INTO "Documents" VALUES ("6", "105", "Invoice_003_Detailed", "Detailed invoice for large project");
INSERT INTO "Documents" VALUES ("7", "102", "Order_002", "Order for new equipment");
INSERT INTO "Documents" VALUES ("8", "106", "Customer_Order_001", "Customer order for custom product");
INSERT INTO "Documents" VALUES ("9", "103", "Sales_Report_Feb", "February sales figures");
INSERT INTO "Documents" VALUES ("10", "107", "Financial_Report_Q1", "Q1 financial performance report");
INSERT INTO "Documents" VALUES ("11", "108", "Team_Meeting_Memo", "Memo for upcoming team meeting");
INSERT INTO "Documents" VALUES ("12", "109", "SLA_Client_B", "Service agreement with client B");
INSERT INTO "Documents" VALUES ("13", "104", "Client_Letter_B", "Follow-up letter to client B");
INSERT INTO "Documents" VALUES ("14", "101", "Invoice_004", "Invoice for consulting services");
INSERT INTO "Documents" VALUES ("15", "105", "Invoice_005_Detailed", "Another detailed invoice");
INSERT INTO "Documents" VALUES ("16", "103", "Sales_Report_Mar", "March sales figures");
INSERT INTO "Documents" VALUES ("17", "107", "Financial_Report_Q2", "Q2 financial performance report");
INSERT INTO "Documents" VALUES ("18", "108", "Project_Update_Memo", "Memo regarding project status update");
INSERT INTO "Documents" VALUES ("19", "109", "SLA_Vendor_C", "Service agreement with vendor C");
INSERT INTO "Documents" VALUES ("20", "110", "Thank_You_Note", "Thank you note to a partner");
INSERT INTO "Documents" VALUES ("21", "101", "Invoice_006", "Invoice for software license");
INSERT INTO "Documents" VALUES ("22", "102", "Order_003", "Order for marketing materials");
INSERT INTO "Documents" VALUES ("23", "103", "Sales_Report_Apr", "April sales figures");
INSERT INTO "Documents" VALUES ("24", "104", "Client_Letter_C", "Letter to client C about new features");
INSERT INTO "Documents" VALUES ("25", "105", "Invoice_007_Detailed", "Final detailed invoice for project X");