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,
"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", "Document Alpha");
INSERT INTO "Documents" VALUES ("102", "1", "Document Beta");
INSERT INTO "Documents" VALUES ("103", "2", "Document Gamma");
INSERT INTO "Documents" VALUES ("104", "3", "Document Delta");
INSERT INTO "Documents" VALUES ("105", "4", "Document Epsilon");
INSERT INTO "Documents" VALUES ("106", "5", "Document Zeta");
INSERT INTO "Documents" VALUES ("107", "2", "Document Eta");
INSERT INTO "Documents" VALUES ("108", "3", "Document Theta");
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", "103");
INSERT INTO "Paragraphs" VALUES ("1007", "104");
INSERT INTO "Paragraphs" VALUES ("1008", "105");
INSERT INTO "Paragraphs" VALUES ("1009", "106");
INSERT INTO "Paragraphs" VALUES ("1010", "107");
INSERT INTO "Paragraphs" VALUES ("1011", "107");
INSERT INTO "Paragraphs" VALUES ("1012", "108");
INSERT INTO "Paragraphs" VALUES ("1013", "108");
INSERT INTO "Paragraphs" VALUES ("1014", "108");