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 ("REP", "Report Template");
INSERT INTO "Ref_Template_Types" VALUES ("MEM", "Memo Template");
INSERT INTO "Ref_Template_Types" VALUES ("AGR", "Agreement Template");
INSERT INTO "Ref_Template_Types" VALUES ("PRO", "Proposal Template");
INSERT INTO "Ref_Template_Types" VALUES ("REC", "Receipt Template");
INSERT INTO "Ref_Template_Types" VALUES ("CON", "Contract Template");
INSERT INTO "Templates" VALUES ("101", "INV", "Standard Invoice Layout");
INSERT INTO "Templates" VALUES ("102", "ORD", "Customer Order Form");
INSERT INTO "Templates" VALUES ("103", "REP", "Monthly Sales Report");
INSERT INTO "Templates" VALUES ("104", "MEM", "Internal Communication Memo");
INSERT INTO "Templates" VALUES ("105", "AGR", "Service Level Agreement");
INSERT INTO "Templates" VALUES ("106", "PRO", "Project Proposal Template");
INSERT INTO "Templates" VALUES ("107", "INV", "Detailed Invoice Layout");
INSERT INTO "Templates" VALUES ("108", "REP", "Quarterly Financial Report");
INSERT INTO "Templates" VALUES ("109", "REC", "Payment Receipt");
INSERT INTO "Templates" VALUES ("110", "CON", "Employment Contract");
INSERT INTO "Templates" VALUES ("111", "MEM", "Meeting Minutes Memo");
INSERT INTO "Templates" VALUES ("112", "ORD", "Online Order Form");
INSERT INTO "Documents" VALUES ("1", "101", "Invoice_001", "Invoice for Q1 services");
INSERT INTO "Documents" VALUES ("2", "102", "Order_001", "Order for new software licenses");
INSERT INTO "Documents" VALUES ("3", "103", "Sales_Report_Jan", "Sales performance for January");
INSERT INTO "Documents" VALUES ("4", "104", "Memo_Meeting_Notes", "Notes from weekly team meeting");
INSERT INTO "Documents" VALUES ("5", "105", "SLA_Client_A", "Service agreement with Client A");
INSERT INTO "Documents" VALUES ("6", "106", "Proposal_Project_X", "Proposal for Project X development");
INSERT INTO "Documents" VALUES ("7", "101", "Invoice_002", "Invoice for consulting services");
INSERT INTO "Documents" VALUES ("8", "107", "Invoice_003_Detailed", "Detailed invoice for large project");
INSERT INTO "Documents" VALUES ("9", "103", "Sales_Report_Feb", "Sales performance for February");
INSERT INTO "Documents" VALUES ("10", "108", "Financial_Report_Q1", "Financial report for the first quarter");
INSERT INTO "Documents" VALUES ("11", "109", "Receipt_001", "Receipt for software purchase");
INSERT INTO "Documents" VALUES ("12", "110", "Contract_Employee_A", "Contract for new employee A");
INSERT INTO "Documents" VALUES ("13", "104", "Memo_Policy_Update", "Memo regarding new company policy");
INSERT INTO "Documents" VALUES ("14", "102", "Order_002", "Order for office supplies");
INSERT INTO "Documents" VALUES ("15", "111", "Memo_Minutes_Board", "Minutes from Board Meeting");
INSERT INTO "Documents" VALUES ("16", "112", "Order_003_Online", "Online order for product Z");
INSERT INTO "Documents" VALUES ("17", "105", "SLA_Client_B", "Service agreement with Client B");
INSERT INTO "Documents" VALUES ("18", "106", "Proposal_Project_Y", "Proposal for Project Y implementation");