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





INSERT INTO "Templates" VALUES ("1", "TypeA", "Standard contract template");
INSERT INTO "Templates" VALUES ("2", "TypeB", "Non-disclosure agreement template");
INSERT INTO "Templates" VALUES ("3", "TypeC", "Employment offer letter template");
INSERT INTO "Templates" VALUES ("4", "TypeD", "Project proposal template");
INSERT INTO "Templates" VALUES ("5", "TypeE", "Invoice template");
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 "Documents" VALUES ("107", "2");
INSERT INTO "Documents" VALUES ("108", "3");
INSERT INTO "Paragraphs" VALUES ("1001", "101");
INSERT INTO "Paragraphs" VALUES ("1002", "101");
INSERT INTO "Paragraphs" VALUES ("1003", "101");
INSERT INTO "Paragraphs" VALUES ("1004", "102");
INSERT INTO "Paragraphs" VALUES ("1005", "102");
INSERT INTO "Paragraphs" VALUES ("1006", "103");
INSERT INTO "Paragraphs" VALUES ("1007", "103");
INSERT INTO "Paragraphs" VALUES ("1008", "103");
INSERT INTO "Paragraphs" VALUES ("1009", "103");
INSERT INTO "Paragraphs" VALUES ("1010", "104");
INSERT INTO "Paragraphs" VALUES ("1011", "105");
INSERT INTO "Paragraphs" VALUES ("1012", "105");
INSERT INTO "Paragraphs" VALUES ("1013", "105");
INSERT INTO "Paragraphs" VALUES ("1014", "105");
INSERT INTO "Paragraphs" VALUES ("1015", "105");
INSERT INTO "Paragraphs" VALUES ("1016", "106");
INSERT INTO "Paragraphs" VALUES ("1017", "107");
INSERT INTO "Paragraphs" VALUES ("1018", "107");
INSERT INTO "Paragraphs" VALUES ("1019", "108");
INSERT INTO "Paragraphs" VALUES ("1020", "108");
INSERT INTO "Paragraphs" VALUES ("1021", "108");
INSERT INTO "Paragraphs" VALUES ("1022", "108");
INSERT INTO "Paragraphs" VALUES ("1023", "108");