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





INSERT INTO "Templates" VALUES ("1", "TypeA");
INSERT INTO "Templates" VALUES ("2", "TypeB");
INSERT INTO "Templates" VALUES ("3", "TypeC");
INSERT INTO "Templates" VALUES ("4", "TypeD");
INSERT INTO "Templates" VALUES ("5", "TypeE");
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", "5");
INSERT INTO "Paragraphs" VALUES ("1001", "101", "Introduction to document 101.");
INSERT INTO "Paragraphs" VALUES ("1002", "101", "Details about the first topic.");
INSERT INTO "Paragraphs" VALUES ("1003", "101", "Conclusion of document 101.");
INSERT INTO "Paragraphs" VALUES ("1004", "102", "Only paragraph in document 102.");
INSERT INTO "Paragraphs" VALUES ("1005", "103", "First paragraph of document 103.");
INSERT INTO "Paragraphs" VALUES ("1006", "103", "Second paragraph of document 103.");
INSERT INTO "Paragraphs" VALUES ("1007", "104", "Document 104 starts here.");
INSERT INTO "Paragraphs" VALUES ("1008", "104", "More content in document 104.");
INSERT INTO "Paragraphs" VALUES ("1009", "104", "Additional details in document 104.");
INSERT INTO "Paragraphs" VALUES ("1010", "104", "Final paragraph of document 104.");
INSERT INTO "Paragraphs" VALUES ("1011", "105", "Document 105 has one paragraph only.");
INSERT INTO "Paragraphs" VALUES ("1012", "106", "Paragraph one of document 106.");
INSERT INTO "Paragraphs" VALUES ("1013", "106", "Paragraph two of document 106.");
INSERT INTO "Paragraphs" VALUES ("1014", "106", "Paragraph three of document 106.");
INSERT INTO "Paragraphs" VALUES ("1015", "106", "Paragraph four of document 106.");
INSERT INTO "Paragraphs" VALUES ("1016", "106", "Paragraph five of document 106.");