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

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"Template_Type_Code" CHAR(15),
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 Document");
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");
INSERT INTO "Templates" VALUES ("1", "TYPE_A");
INSERT INTO "Templates" VALUES ("2", "TYPE_B");
INSERT INTO "Templates" VALUES ("3", "TYPE_C");
INSERT INTO "Templates" VALUES ("4", "TYPE_D");
INSERT INTO "Templates" VALUES ("5", "TYPE_E");
INSERT INTO "Templates" VALUES ("6", "TYPE_A");
INSERT INTO "Templates" VALUES ("7", "TYPE_B");
INSERT INTO "Templates" VALUES ("8", "TYPE_A");
INSERT INTO "Documents" VALUES ("101", "1", "Contract Agreement");
INSERT INTO "Documents" VALUES ("102", "1", "NDA Agreement");
INSERT INTO "Documents" VALUES ("103", "2", "Annual Financial Report 2023");
INSERT INTO "Documents" VALUES ("104", "3", "User Guide for Product X");
INSERT INTO "Documents" VALUES ("105", "1", "Service Agreement");
INSERT INTO "Documents" VALUES ("106", "4", "Summer Campaign Brochure");
INSERT INTO "Documents" VALUES ("107", "5", "Employee Handbook");
INSERT INTO "Documents" VALUES ("108", "6", "Lease Agreement");
INSERT INTO "Documents" VALUES ("109", "7", "Quarterly Financial Summary");
INSERT INTO "Documents" VALUES ("110", "8", "Partnership Agreement");
INSERT INTO "Documents" VALUES ("111", "1", "Consulting Agreement");
INSERT INTO "Documents" VALUES ("112", "2", "Budget Report");
INSERT INTO "Documents" VALUES ("113", "3", "Installation Manual");
INSERT INTO "Documents" VALUES ("114", "4", "Product Launch Flyer");
INSERT INTO "Documents" VALUES ("115", "1", "Confidentiality Agreement");
INSERT INTO "Paragraphs" VALUES ("201", "This document outlines the terms and conditions.");
INSERT INTO "Paragraphs" VALUES ("202", "All financial data is confidential.");
INSERT INTO "Paragraphs" VALUES ("203", "Installation steps are described in detail.");
INSERT INTO "Paragraphs" VALUES ("204", "Marketing strategies for the upcoming quarter.");
INSERT INTO "Paragraphs" VALUES ("205", "Employee responsibilities and code of conduct.");
INSERT INTO "Paragraphs" VALUES ("206", "Legal obligations and liabilities.");
INSERT INTO "Paragraphs" VALUES ("207", "Summary of financial performance.");
INSERT INTO "Paragraphs" VALUES ("208", "Instructions for product setup.");
INSERT INTO "Paragraphs" VALUES ("209", "Terms of service and agreement duration.");
INSERT INTO "Paragraphs" VALUES ("210", "Confidentiality clauses and data protection.");