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 "Ref_Template_Types" (
"Template_Type_Code" CHAR(15),
"Template_Type_Description" VARCHAR(255),
PRIMARY KEY ("Template_Type_Code")
);

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





INSERT INTO "Ref_Template_Types" VALUES ("FORM", "Standard Form");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Detailed Report");
INSERT INTO "Ref_Template_Types" VALUES ("LETTER", "Official Letter");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Internal Memorandum");
INSERT INTO "Ref_Template_Types" VALUES ("AGREEMENT", "Legal Agreement");
INSERT INTO "Templates" VALUES ("101", "Invoice Template v1.0");
INSERT INTO "Templates" VALUES ("102", "Contract Template A");
INSERT INTO "Templates" VALUES ("103", "Report Template Q3");
INSERT INTO "Templates" VALUES ("104", "Letterhead Template");
INSERT INTO "Templates" VALUES ("105", "Memo Template General");
INSERT INTO "Templates" VALUES ("106", "Invoice Template v2.0");
INSERT INTO "Templates" VALUES ("107", "Contract Template B");
INSERT INTO "Documents" VALUES ("1", "101");
INSERT INTO "Documents" VALUES ("2", "102");
INSERT INTO "Documents" VALUES ("3", "101");
INSERT INTO "Documents" VALUES ("4", "103");
INSERT INTO "Documents" VALUES ("5", "104");
INSERT INTO "Documents" VALUES ("6", "101");
INSERT INTO "Documents" VALUES ("7", "102");
INSERT INTO "Documents" VALUES ("8", "105");
INSERT INTO "Documents" VALUES ("9", "103");
INSERT INTO "Documents" VALUES ("10", "106");
INSERT INTO "Documents" VALUES ("11", "101");
INSERT INTO "Documents" VALUES ("12", "107");
INSERT INTO "Documents" VALUES ("13", "102");
INSERT INTO "Documents" VALUES ("14", "106");
INSERT INTO "Documents" VALUES ("15", "101");
INSERT INTO "Paragraphs" VALUES ("1001", "1");
INSERT INTO "Paragraphs" VALUES ("1002", "1");
INSERT INTO "Paragraphs" VALUES ("1003", "2");
INSERT INTO "Paragraphs" VALUES ("1004", "3");
INSERT INTO "Paragraphs" VALUES ("1005", "4");
INSERT INTO "Paragraphs" VALUES ("1006", "4");
INSERT INTO "Paragraphs" VALUES ("1007", "5");
INSERT INTO "Paragraphs" VALUES ("1008", "6");
INSERT INTO "Paragraphs" VALUES ("1009", "7");
INSERT INTO "Paragraphs" VALUES ("1010", "8");
INSERT INTO "Paragraphs" VALUES ("1011", "9");
INSERT INTO "Paragraphs" VALUES ("1012", "10");
INSERT INTO "Paragraphs" VALUES ("1013", "11");
INSERT INTO "Paragraphs" VALUES ("1014", "12");
INSERT INTO "Paragraphs" VALUES ("1015", "13");
INSERT INTO "Paragraphs" VALUES ("1016", "14");
INSERT INTO "Paragraphs" VALUES ("1017", "15");