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 "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", "102");
INSERT INTO "Documents" VALUES ("6", "104");
INSERT INTO "Documents" VALUES ("7", "101");
INSERT INTO "Documents" VALUES ("8", "105");
INSERT INTO "Documents" VALUES ("9", "103");
INSERT INTO "Documents" VALUES ("10", "106");
INSERT INTO "Paragraphs" VALUES ("1", "1");
INSERT INTO "Paragraphs" VALUES ("2", "1");
INSERT INTO "Paragraphs" VALUES ("3", "2");
INSERT INTO "Paragraphs" VALUES ("4", "3");
INSERT INTO "Paragraphs" VALUES ("5", "3");
INSERT INTO "Paragraphs" VALUES ("6", "4");
INSERT INTO "Paragraphs" VALUES ("7", "5");
INSERT INTO "Paragraphs" VALUES ("8", "6");
INSERT INTO "Paragraphs" VALUES ("9", "7");
INSERT INTO "Paragraphs" VALUES ("10", "8");
INSERT INTO "Paragraphs" VALUES ("11", "9");
INSERT INTO "Paragraphs" VALUES ("12", "10");
INSERT INTO "Ref_Template_Types" VALUES ("FORM", "Standard Form");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Monthly 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", "General Purpose Template");
INSERT INTO "Templates" VALUES ("102", "Project Report Template");
INSERT INTO "Templates" VALUES ("103", "Client Communication Template");
INSERT INTO "Templates" VALUES ("104", "Internal Memo Template");
INSERT INTO "Templates" VALUES ("105", "Contract Template");
INSERT INTO "Templates" VALUES ("106", "Meeting Minutes Template");