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 UNIQUE,
"Template_ID" INT,
"Document_Name" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY ("Template_ID") REFERENCES "Templates"("Template_ID")
);

CREATE TABLE "Paragraphs" (
"Paragraph_ID" INT,
"Paragraph_Text" VARCHAR(255),
PRIMARY KEY ("Paragraph_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),
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 ("REP", "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 "Ref_Template_Types" VALUES ("PRO", "Proposal Template");
INSERT INTO "Ref_Template_Types" VALUES ("REC", "Receipt Template");
INSERT INTO "Templates" VALUES ("101", "INV");
INSERT INTO "Templates" VALUES ("102", "REP");
INSERT INTO "Templates" VALUES ("103", "LTR");
INSERT INTO "Templates" VALUES ("104", "INV");
INSERT INTO "Templates" VALUES ("105", "MEM");
INSERT INTO "Templates" VALUES ("106", "REP");
INSERT INTO "Templates" VALUES ("107", "AGR");
INSERT INTO "Templates" VALUES ("108", "PRO");
INSERT INTO "Templates" VALUES ("109", "LTR");
INSERT INTO "Templates" VALUES ("110", "REC");
INSERT INTO "Templates" VALUES ("111", "INV");
INSERT INTO "Templates" VALUES ("112", "AGR");
INSERT INTO "Documents" VALUES ("1", "101", "Invoice_001");
INSERT INTO "Documents" VALUES ("2", "102", "Monthly_Report_Q1");
INSERT INTO "Documents" VALUES ("3", "103", "Client_Letter_A");
INSERT INTO "Documents" VALUES ("4", "104", "Invoice_002");
INSERT INTO "Documents" VALUES ("5", "105", "Internal_Memo_ProjectX");
INSERT INTO "Documents" VALUES ("6", "106", "Annual_Report_2023");
INSERT INTO "Documents" VALUES ("7", "101", "Invoice_003");
INSERT INTO "Documents" VALUES ("8", "107", "Service_Agreement_V1");
INSERT INTO "Documents" VALUES ("9", "103", "Client_Letter_B");
INSERT INTO "Documents" VALUES ("10", "108", "New_Project_Proposal");
INSERT INTO "Documents" VALUES ("11", "101", "Invoice_004");
INSERT INTO "Documents" VALUES ("12", "109", "Follow_Up_Letter");
INSERT INTO "Documents" VALUES ("13", "110", "Payment_Receipt_123");
INSERT INTO "Documents" VALUES ("14", "102", "Quarterly_Report_Q2");
INSERT INTO "Documents" VALUES ("15", "105", "Team_Meeting_Memo");
INSERT INTO "Documents" VALUES ("16", "111", "Invoice_005");
INSERT INTO "Documents" VALUES ("17", "112", "Partnership_Agreement");
INSERT INTO "Paragraphs" VALUES ("1", "This is the first paragraph of the document.");
INSERT INTO "Paragraphs" VALUES ("2", "Second paragraph with some details.");
INSERT INTO "Paragraphs" VALUES ("3", "Concluding remarks for the document.");
INSERT INTO "Paragraphs" VALUES ("4", "Introduction to the report.");
INSERT INTO "Paragraphs" VALUES ("5", "Data analysis section.");
INSERT INTO "Paragraphs" VALUES ("6", "Summary of findings.");
INSERT INTO "Paragraphs" VALUES ("7", "Opening salutation.");
INSERT INTO "Paragraphs" VALUES ("8", "Body of the letter.");
INSERT INTO "Paragraphs" VALUES ("9", "Closing remarks.");
INSERT INTO "Paragraphs" VALUES ("10", "Memo subject and date.");
INSERT INTO "Paragraphs" VALUES ("11", "Main content of the memo.");
INSERT INTO "Paragraphs" VALUES ("12", "Action items.");