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,
"Paragraph_Text" VARCHAR(255),
PRIMARY KEY ("Paragraph_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 UNIQUE,
"Template_Type_Code" CHAR(15),
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID"),
FOREIGN KEY ("Template_Type_Code") REFERENCES "Ref_Template_Types"("Template_Type_Code")
);





INSERT INTO "Ref_Template_Types" VALUES ("TYPE_A", "Legal Contract");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_B", "Financial Report");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_C", "Technical Manual");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_D", "Marketing Brochure");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_E", "HR Policy Document");
INSERT INTO "Templates" VALUES ("101", "TYPE_A", "Standard legal contract template for agreements");
INSERT INTO "Templates" VALUES ("102", "TYPE_B", "Quarterly financial report template");
INSERT INTO "Templates" VALUES ("103", "TYPE_C", "User guide for software installation");
INSERT INTO "Templates" VALUES ("104", "TYPE_D", "Product marketing brochure template");
INSERT INTO "Templates" VALUES ("105", "TYPE_E", "Employee handbook and policies");
INSERT INTO "Documents" VALUES ("1001", "101");
INSERT INTO "Documents" VALUES ("1002", "102");
INSERT INTO "Documents" VALUES ("1003", "101");
INSERT INTO "Documents" VALUES ("1004", "104");
INSERT INTO "Documents" VALUES ("1005", "105");
INSERT INTO "Documents" VALUES ("1006", "103");
INSERT INTO "Documents" VALUES ("1007", "102");
INSERT INTO "Documents" VALUES ("1008", "105");
INSERT INTO "Paragraphs" VALUES ("201", "This contract is legally binding and covers all terms.");
INSERT INTO "Paragraphs" VALUES ("202", "The financial report summarizes the quarterly earnings.");
INSERT INTO "Paragraphs" VALUES ("203", "Installation steps for the software are detailed here.");
INSERT INTO "Paragraphs" VALUES ("204", "Marketing strategies for the new product launch.");
INSERT INTO "Paragraphs" VALUES ("205", "Company policies and employee responsibilities.");
INSERT INTO "Paragraphs" VALUES ("206", "Additional clauses for contract amendments.");
INSERT INTO "Paragraphs" VALUES ("207", "Financial data analysis and projections.");
INSERT INTO "Paragraphs" VALUES ("208", "Technical support contact information.");