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

CREATE TABLE "Paragraphs" (
"Paragraph_ID" INT,
"Document_ID" INT,
"Paragraph_Text" VARCHAR(255),
PRIMARY KEY ("Paragraph_ID"),
FOREIGN KEY ("Document_ID") REFERENCES "Documents"("Document_ID")
);

CREATE TABLE "Templates" (
"Template_ID" INT,
"Template_Type_Code" CHAR(15),
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Templates" VALUES ("1", "TypeA", "Template for reports");
INSERT INTO "Templates" VALUES ("2", "TypeB", "Template for letters");
INSERT INTO "Templates" VALUES ("3", "TypeC", "Template for memos");
INSERT INTO "Templates" VALUES ("4", "TypeD", "Template for contracts");
INSERT INTO "Documents" VALUES ("101", "1");
INSERT INTO "Documents" VALUES ("102", "1");
INSERT INTO "Documents" VALUES ("103", "2");
INSERT INTO "Documents" VALUES ("104", "3");
INSERT INTO "Documents" VALUES ("105", "4");
INSERT INTO "Documents" VALUES ("106", "2");
INSERT INTO "Paragraphs" VALUES ("1001", "101", "This document covers Brazil's economic growth.");
INSERT INTO "Paragraphs" VALUES ("1002", "101", "Ireland has seen a rise in tech jobs.");
INSERT INTO "Paragraphs" VALUES ("1003", "102", "Brazil is known for its biodiversity.");
INSERT INTO "Paragraphs" VALUES ("1004", "102", "The culture of Brazil is diverse.");
INSERT INTO "Paragraphs" VALUES ("1005", "103", "Ireland's history is rich and complex.");
INSERT INTO "Paragraphs" VALUES ("1006", "103", "This letter is regarding the Ireland office.");
INSERT INTO "Paragraphs" VALUES ("1007", "104", "Brazil and Ireland have trade agreements.");
INSERT INTO "Paragraphs" VALUES ("1008", "104", "This memo discusses Brazil's agriculture.");
INSERT INTO "Paragraphs" VALUES ("1009", "105", "Ireland's tourism sector is growing.");
INSERT INTO "Paragraphs" VALUES ("1010", "105", "Brazilian culture influences many areas.");
INSERT INTO "Paragraphs" VALUES ("1011", "106", "This document mentions Brazil only.");
INSERT INTO "Paragraphs" VALUES ("1012", "106", "No mention of Ireland here.");