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 "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", "REP");
INSERT INTO "Templates" VALUES ("106", "LTR");
INSERT INTO "Templates" VALUES ("107", "MEM");
INSERT INTO "Templates" VALUES ("108", "INV");
INSERT INTO "Templates" VALUES ("109", "AGR");
INSERT INTO "Templates" VALUES ("110", "REP");
INSERT INTO "Documents" VALUES ("1", "101", "Invoice_001");
INSERT INTO "Documents" VALUES ("2", "101", "Invoice_002");
INSERT INTO "Documents" VALUES ("3", "102", "Report_Q1");
INSERT INTO "Documents" VALUES ("4", "103", "Letter_ClientA");
INSERT INTO "Documents" VALUES ("5", "104", "Invoice_003");
INSERT INTO "Documents" VALUES ("6", "105", "Report_Q2");
INSERT INTO "Documents" VALUES ("7", "103", "Letter_ClientB");
INSERT INTO "Documents" VALUES ("8", "107", "Memo_Meeting");
INSERT INTO "Documents" VALUES ("9", "108", "Invoice_004");
INSERT INTO "Documents" VALUES ("10", "102", "Report_Annual");
INSERT INTO "Documents" VALUES ("11", "109", "Agreement_NDA");
INSERT INTO "Documents" VALUES ("12", "101", "Invoice_005");
INSERT INTO "Documents" VALUES ("13", "103", "Letter_Supplier");
INSERT INTO "Documents" VALUES ("14", "107", "Memo_Project");
INSERT INTO "Documents" VALUES ("15", "104", "Invoice_006");
INSERT INTO "Paragraphs" VALUES ("1", "This is the first paragraph of document 1.");
INSERT INTO "Paragraphs" VALUES ("2", "This is the second paragraph of document 1.");
INSERT INTO "Paragraphs" VALUES ("3", "Report summary for Q1.");
INSERT INTO "Paragraphs" VALUES ("4", "Dear Client A, we are writing to inform you...");
INSERT INTO "Paragraphs" VALUES ("5", "Invoice details for transaction 003.");
INSERT INTO "Paragraphs" VALUES ("6", "Quarter 2 performance overview.");
INSERT INTO "Paragraphs" VALUES ("7", "Regarding your recent inquiry, Client B...");
INSERT INTO "Paragraphs" VALUES ("8", "Minutes of the weekly team meeting.");
INSERT INTO "Paragraphs" VALUES ("9", "Final invoice for services rendered.");
INSERT INTO "Paragraphs" VALUES ("10", "Annual report highlights.");
INSERT INTO "Paragraphs" VALUES ("11", "Non-disclosure agreement terms.");
INSERT INTO "Paragraphs" VALUES ("12", "Payment due for invoice 005.");
INSERT INTO "Paragraphs" VALUES ("13", "To our valued supplier, thank you for your cooperation.");
INSERT INTO "Paragraphs" VALUES ("14", "Project update for phase 2.");
INSERT INTO "Paragraphs" VALUES ("15", "Invoice 006 details.");