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,
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", "TYPE_A");
INSERT INTO "Templates" VALUES ("2", "TYPE_B");
INSERT INTO "Templates" VALUES ("3", "TYPE_C");
INSERT INTO "Templates" VALUES ("4", "TYPE_D");
INSERT INTO "Templates" VALUES ("5", "TYPE_E_LONG");
INSERT INTO "Templates" VALUES ("6", "TYPE_F");
INSERT INTO "Templates" VALUES ("7", "TYPE_G");
INSERT INTO "Templates" VALUES ("8", "TYPE_H");
INSERT INTO "Templates" VALUES ("9", "TYPE_I");
INSERT INTO "Templates" VALUES ("10", "TYPE_J");
INSERT INTO "Documents" VALUES ("101", "1");
INSERT INTO "Documents" VALUES ("102", "2");
INSERT INTO "Documents" VALUES ("103", "3");
INSERT INTO "Documents" VALUES ("104", "4");
INSERT INTO "Documents" VALUES ("105", "5");
INSERT INTO "Documents" VALUES ("106", "6");
INSERT INTO "Documents" VALUES ("107", "7");
INSERT INTO "Documents" VALUES ("108", "8");
INSERT INTO "Documents" VALUES ("109", "9");
INSERT INTO "Documents" VALUES ("110", "10");
INSERT INTO "Documents" VALUES ("111", "1");
INSERT INTO "Documents" VALUES ("112", "2");
INSERT INTO "Documents" VALUES ("113", "3");
INSERT INTO "Documents" VALUES ("114", "4");
INSERT INTO "Documents" VALUES ("115", "5");
INSERT INTO "Documents" VALUES ("116", "6");
INSERT INTO "Documents" VALUES ("117", "7");
INSERT INTO "Documents" VALUES ("118", "8");
INSERT INTO "Documents" VALUES ("119", "9");
INSERT INTO "Documents" VALUES ("120", "10");
INSERT INTO "Documents" VALUES ("121", "1");
INSERT INTO "Documents" VALUES ("122", "2");
INSERT INTO "Documents" VALUES ("123", "3");
INSERT INTO "Documents" VALUES ("124", "4");
INSERT INTO "Documents" VALUES ("125", "5");
INSERT INTO "Documents" VALUES ("126", "6");
INSERT INTO "Documents" VALUES ("127", "7");
INSERT INTO "Documents" VALUES ("128", "8");
INSERT INTO "Documents" VALUES ("129", "9");
INSERT INTO "Documents" VALUES ("130", "10");
INSERT INTO "Documents" VALUES ("131", "1");
INSERT INTO "Documents" VALUES ("132", "2");
INSERT INTO "Documents" VALUES ("133", "3");
INSERT INTO "Documents" VALUES ("134", "4");
INSERT INTO "Documents" VALUES ("135", "5");
INSERT INTO "Documents" VALUES ("136", "6");
INSERT INTO "Documents" VALUES ("137", "7");
INSERT INTO "Documents" VALUES ("138", "8");
INSERT INTO "Documents" VALUES ("139", "9");
INSERT INTO "Documents" VALUES ("140", "10");
INSERT INTO "Documents" VALUES ("141", "1");
INSERT INTO "Documents" VALUES ("142", "2");
INSERT INTO "Documents" VALUES ("143", "3");
INSERT INTO "Documents" VALUES ("144", "4");
INSERT INTO "Documents" VALUES ("145", "5");
INSERT INTO "Documents" VALUES ("146", "6");
INSERT INTO "Documents" VALUES ("147", "7");
INSERT INTO "Documents" VALUES ("148", "8");
INSERT INTO "Documents" VALUES ("149", "9");
INSERT INTO "Documents" VALUES ("150", "10");
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", "104");
INSERT INTO "Paragraphs" VALUES ("1006", "105");
INSERT INTO "Paragraphs" VALUES ("1007", "106");
INSERT INTO "Paragraphs" VALUES ("1008", "107");
INSERT INTO "Paragraphs" VALUES ("1009", "108");
INSERT INTO "Paragraphs" VALUES ("1010", "109");
INSERT INTO "Paragraphs" VALUES ("1011", "110");
INSERT INTO "Paragraphs" VALUES ("1012", "111");
INSERT INTO "Paragraphs" VALUES ("1013", "112");
INSERT INTO "Paragraphs" VALUES ("1014", "113");
INSERT INTO "Paragraphs" VALUES ("1015", "114");
INSERT INTO "Paragraphs" VALUES ("1016", "115");
INSERT INTO "Paragraphs" VALUES ("1017", "116");
INSERT INTO "Paragraphs" VALUES ("1018", "117");
INSERT INTO "Paragraphs" VALUES ("1019", "118");
INSERT INTO "Paragraphs" VALUES ("1020", "119");
INSERT INTO "Paragraphs" VALUES ("1021", "120");
INSERT INTO "Paragraphs" VALUES ("1022", "121");
INSERT INTO "Paragraphs" VALUES ("1023", "122");
INSERT INTO "Paragraphs" VALUES ("1024", "123");
INSERT INTO "Paragraphs" VALUES ("1025", "124");
INSERT INTO "Paragraphs" VALUES ("1026", "125");
INSERT INTO "Paragraphs" VALUES ("1027", "126");
INSERT INTO "Paragraphs" VALUES ("1028", "127");
INSERT INTO "Paragraphs" VALUES ("1029", "128");
INSERT INTO "Paragraphs" VALUES ("1030", "129");
INSERT INTO "Paragraphs" VALUES ("1031", "130");
INSERT INTO "Paragraphs" VALUES ("1032", "131");
INSERT INTO "Paragraphs" VALUES ("1033", "132");
INSERT INTO "Paragraphs" VALUES ("1034", "133");
INSERT INTO "Paragraphs" VALUES ("1035", "134");
INSERT INTO "Paragraphs" VALUES ("1036", "135");
INSERT INTO "Paragraphs" VALUES ("1037", "136");
INSERT INTO "Paragraphs" VALUES ("1038", "137");
INSERT INTO "Paragraphs" VALUES ("1039", "138");
INSERT INTO "Paragraphs" VALUES ("1040", "139");
INSERT INTO "Paragraphs" VALUES ("1041", "140");
INSERT INTO "Paragraphs" VALUES ("1042", "141");
INSERT INTO "Paragraphs" VALUES ("1043", "142");
INSERT INTO "Paragraphs" VALUES ("1044", "143");
INSERT INTO "Paragraphs" VALUES ("1045", "144");
INSERT INTO "Paragraphs" VALUES ("1046", "145");
INSERT INTO "Paragraphs" VALUES ("1047", "146");
INSERT INTO "Paragraphs" VALUES ("1048", "147");
INSERT INTO "Paragraphs" VALUES ("1049", "148");
INSERT INTO "Paragraphs" VALUES ("1050", "149");