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,
"Document_Name" VARCHAR(255),
PRIMARY KEY ("Document_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,
"Version_Number" INT,
"Template_Type_Code" CHAR(15),
PRIMARY KEY ("Template_ID"),
FOREIGN KEY ("Template_Type_Code") REFERENCES "Ref_Template_Types"("Template_Type_Code")
);





INSERT INTO "Documents" VALUES ("1", "Employee Handbook");
INSERT INTO "Documents" VALUES ("2", "Safety Guidelines");
INSERT INTO "Documents" VALUES ("3", "Project Plan");
INSERT INTO "Documents" VALUES ("4", "Marketing Strategy");
INSERT INTO "Documents" VALUES ("5", "Annual Report");
INSERT INTO "Paragraphs" VALUES ("1", "All employees must adhere to company policies.");
INSERT INTO "Paragraphs" VALUES ("2", "Emergency exits are located at the end of each corridor.");
INSERT INTO "Paragraphs" VALUES ("3", "Project milestones must be met on schedule.");
INSERT INTO "Paragraphs" VALUES ("4", "Marketing campaigns should target the 18-35 demographic.");
INSERT INTO "Paragraphs" VALUES ("5", "Financial results are audited annually.");
INSERT INTO "Ref_Template_Types" VALUES ("HR_POLICIES", "Human Resources Policies");
INSERT INTO "Ref_Template_Types" VALUES ("SAFETY_GUIDE", "Safety Guidelines");
INSERT INTO "Ref_Template_Types" VALUES ("PROJECT_PLAN", "Project Planning Documents");
INSERT INTO "Ref_Template_Types" VALUES ("MARKETING", "Marketing Materials");
INSERT INTO "Ref_Template_Types" VALUES ("FIN_REPORT", "Financial Reports");
INSERT INTO "Templates" VALUES ("101", "1", "HR_POLICIES");
INSERT INTO "Templates" VALUES ("102", "2", "HR_POLICIES");
INSERT INTO "Templates" VALUES ("103", "1", "SAFETY_GUIDE");
INSERT INTO "Templates" VALUES ("104", "3", "PROJECT_PLAN");
INSERT INTO "Templates" VALUES ("105", "1", "MARKETING");
INSERT INTO "Templates" VALUES ("106", "2", "MARKETING");
INSERT INTO "Templates" VALUES ("107", "1", "FIN_REPORT");
INSERT INTO "Templates" VALUES ("108", "2", "FIN_REPORT");
INSERT INTO "Templates" VALUES ("109", "1", "PROJECT_PLAN");
INSERT INTO "Templates" VALUES ("110", "4", "HR_POLICIES");