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) 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),
"Date_Effective_From" DATETIME,
PRIMARY KEY ("Template_ID"),
FOREIGN KEY ("Template_Type_Code") REFERENCES "Ref_Template_Types"("Template_Type_Code")
);





INSERT INTO "Documents" VALUES ("1", "Project Proposal", "Detailed plan for new project");
INSERT INTO "Documents" VALUES ("2", "Meeting Minutes", "Summary of discussion and decisions");
INSERT INTO "Documents" VALUES ("3", "Invoice Template", "Standard invoice format");
INSERT INTO "Documents" VALUES ("4", "Contract Agreement", "Legal binding document");
INSERT INTO "Documents" VALUES ("5", "Expense Report", "Record of business expenses");
INSERT INTO "Ref_Template_Types" VALUES ("PROPOSAL", "Project Proposal Template");
INSERT INTO "Ref_Template_Types" VALUES ("MINUTES", "Meeting Minutes Template");
INSERT INTO "Ref_Template_Types" VALUES ("INVOICE", "Financial Invoice Template");
INSERT INTO "Ref_Template_Types" VALUES ("CONTRACT", "Legal Contract Template");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Expense Report Template");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Internal Memorandum Template");
INSERT INTO "Templates" VALUES ("101", "3", "PROPOSAL", "2023-01-01 00:00:00");
INSERT INTO "Templates" VALUES ("102", "1", "MINUTES", "2023-02-15 00:00:00");
INSERT INTO "Templates" VALUES ("103", "5", "INVOICE", "2023-03-10 00:00:00");
INSERT INTO "Templates" VALUES ("104", "2", "CONTRACT", "2023-04-20 00:00:00");
INSERT INTO "Templates" VALUES ("105", "4", "REPORT", "2023-05-01 00:00:00");
INSERT INTO "Templates" VALUES ("106", "1", "PROPOSAL", "2023-06-01 00:00:00");
INSERT INTO "Templates" VALUES ("107", "2", "MINUTES", "2023-07-01 00:00:00");
INSERT INTO "Templates" VALUES ("108", "1", "INVOICE", "2023-08-01 00:00:00");
INSERT INTO "Templates" VALUES ("109", "3", "CONTRACT", "2023-09-01 00:00:00");
INSERT INTO "Templates" VALUES ("110", "1", "REPORT", "2023-10-01 00:00:00");
INSERT INTO "Templates" VALUES ("111", "0", "MEMO", "2023-11-01 00:00:00");