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),
"Document_Description" VARCHAR(255),
PRIMARY KEY ("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 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", "Company policies and procedures for employees");
INSERT INTO "Documents" VALUES ("2", "Safety Guidelines", "Workplace safety instructions and protocols");
INSERT INTO "Documents" VALUES ("3", "Project Plan", "Detailed plan for project execution and milestones");
INSERT INTO "Documents" VALUES ("4", "Marketing Strategy", "Annual marketing and advertising strategy overview");
INSERT INTO "Documents" VALUES ("5", "Financial Report", "Quarterly financial performance and analysis");
INSERT INTO "Ref_Template_Types" VALUES ("HR_DOC", "Human Resources Document");
INSERT INTO "Ref_Template_Types" VALUES ("SAFETY_DOC", "Safety Document");
INSERT INTO "Ref_Template_Types" VALUES ("PROJ_DOC", "Project Document");
INSERT INTO "Ref_Template_Types" VALUES ("MKT_DOC", "Marketing Document");
INSERT INTO "Ref_Template_Types" VALUES ("FIN_DOC", "Financial Document");
INSERT INTO "Templates" VALUES ("101", "1", "HR_DOC");
INSERT INTO "Templates" VALUES ("102", "2", "HR_DOC");
INSERT INTO "Templates" VALUES ("103", "1", "SAFETY_DOC");
INSERT INTO "Templates" VALUES ("104", "3", "PROJ_DOC");
INSERT INTO "Templates" VALUES ("105", "1", "MKT_DOC");
INSERT INTO "Templates" VALUES ("106", "2", "MKT_DOC");
INSERT INTO "Templates" VALUES ("107", "1", "FIN_DOC");
INSERT INTO "Templates" VALUES ("108", "1", "PROJ_DOC");
INSERT INTO "Templates" VALUES ("109", "4", "HR_DOC");
INSERT INTO "Templates" VALUES ("110", "1", "SAFETY_DOC");