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,
"Document_ID" INT,
PRIMARY KEY ("Paragraph_ID"),
FOREIGN KEY ("Document_ID") REFERENCES "Documents"("Document_ID")
);

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Templates" VALUES ("1", "Standard Business Letter");
INSERT INTO "Templates" VALUES ("2", "Project Proposal Template");
INSERT INTO "Templates" VALUES ("3", "Meeting Minutes Template");
INSERT INTO "Templates" VALUES ("4", "Invoice Template");
INSERT INTO "Templates" VALUES ("5", "Research Paper Template");
INSERT INTO "Templates" VALUES ("6", "Marketing Brochure Template");
INSERT INTO "Documents" VALUES ("101", "1", "Letter to Client A");
INSERT INTO "Documents" VALUES ("102", "1", "Letter to Supplier B");
INSERT INTO "Documents" VALUES ("103", "2", "Q1 Project Proposal");
INSERT INTO "Documents" VALUES ("104", "3", "Team Meeting Minutes 2023-10-26");
INSERT INTO "Documents" VALUES ("105", "1", "Letter to Partner C");
INSERT INTO "Documents" VALUES ("106", "4", "Invoice #2023-001");
INSERT INTO "Documents" VALUES ("107", "2", "Q2 Project Proposal");
INSERT INTO "Documents" VALUES ("108", "5", "Research Paper Draft 1");
INSERT INTO "Documents" VALUES ("109", "3", "Board Meeting Minutes 2023-11-01");
INSERT INTO "Documents" VALUES ("110", "4", "Invoice #2023-002");
INSERT INTO "Documents" VALUES ("111", "6", "Product Launch Brochure");
INSERT INTO "Documents" VALUES ("112", "1", "Follow-up Letter D");
INSERT INTO "Paragraphs" VALUES ("1001", "101");
INSERT INTO "Paragraphs" VALUES ("1002", "101");
INSERT INTO "Paragraphs" VALUES ("1003", "102");
INSERT INTO "Paragraphs" VALUES ("1004", "103");
INSERT INTO "Paragraphs" VALUES ("1005", "103");
INSERT INTO "Paragraphs" VALUES ("1006", "104");
INSERT INTO "Paragraphs" VALUES ("1007", "105");
INSERT INTO "Paragraphs" VALUES ("1008", "106");
INSERT INTO "Paragraphs" VALUES ("1009", "107");
INSERT INTO "Paragraphs" VALUES ("1010", "108");
INSERT INTO "Paragraphs" VALUES ("1011", "108");
INSERT INTO "Paragraphs" VALUES ("1012", "109");
INSERT INTO "Paragraphs" VALUES ("1013", "110");
INSERT INTO "Paragraphs" VALUES ("1014", "111");
INSERT INTO "Paragraphs" VALUES ("1015", "112");