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,
"Template_ID" INT,
"Document_Name" VARCHAR(255),
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) UNIQUE,
"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 Agreement");
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", "Internal Memo");
INSERT INTO "Templates" VALUES ("101", "TYPE_A", "Standard legal contract template");
INSERT INTO "Templates" VALUES ("102", "TYPE_B", "Quarterly financial summary template");
INSERT INTO "Templates" VALUES ("103", "TYPE_C", "User guide for software product");
INSERT INTO "Templates" VALUES ("104", "TYPE_D", "Product launch brochure template");
INSERT INTO "Templates" VALUES ("105", "TYPE_E", "Company internal communication memo");
INSERT INTO "Documents" VALUES ("1001", "101", "Contract with Vendor A");
INSERT INTO "Documents" VALUES ("1002", "102", "Q1 Financial Report 2024");
INSERT INTO "Documents" VALUES ("1003", "103", "Software User Guide v2");
INSERT INTO "Documents" VALUES ("1004", "101", "Contract with Vendor B");
INSERT INTO "Documents" VALUES ("1005", "105", "Staff Meeting Memo March");
INSERT INTO "Documents" VALUES ("1006", "104", "New Product Launch Brochure");
INSERT INTO "Documents" VALUES ("1007", "102", "Q2 Financial Report 2024");
INSERT INTO "Paragraphs" VALUES ("201", "This contract is legally binding between parties.");
INSERT INTO "Paragraphs" VALUES ("202", "The financial report summarizes quarterly earnings.");
INSERT INTO "Paragraphs" VALUES ("203", "This manual explains software installation steps.");
INSERT INTO "Paragraphs" VALUES ("204", "Our new product offers innovative features.");
INSERT INTO "Paragraphs" VALUES ("205", "Please attend the staff meeting on Friday.");
INSERT INTO "Paragraphs" VALUES ("206", "Terms and conditions apply as stated.");
INSERT INTO "Paragraphs" VALUES ("207", "Revenue increased by 15% compared to last quarter.");
INSERT INTO "Paragraphs" VALUES ("208", "Follow the instructions carefully to avoid errors.");
INSERT INTO "Paragraphs" VALUES ("209", "Marketing strategies focus on digital channels.");
INSERT INTO "Paragraphs" VALUES ("210", "Meeting agenda includes project updates and deadlines.");