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,
PRIMARY KEY ("Document_ID"),
FOREIGN KEY ("Template_ID") REFERENCES "Templates"("Template_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,
"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", "Standard Contract Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_B", "Non-Disclosure Agreement Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_C", "Employment Offer Letter Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_D", "Invoice Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_E", "Project Proposal Template");
INSERT INTO "Templates" VALUES ("101", "TYPE_A", "Contract template for standard client agreements");
INSERT INTO "Templates" VALUES ("102", "TYPE_B", "Template for NDAs with partners and vendors");
INSERT INTO "Templates" VALUES ("103", "TYPE_C", "Offer letter template for new hires");
INSERT INTO "Templates" VALUES ("104", "TYPE_D", "Invoice template with tax calculations");
INSERT INTO "Templates" VALUES ("105", "TYPE_E", "Proposal template for new projects");
INSERT INTO "Templates" VALUES ("106", "TYPE_A", "Alternate contract template with updated clauses");
INSERT INTO "Documents" VALUES ("1001", "101");
INSERT INTO "Documents" VALUES ("1002", "102");
INSERT INTO "Documents" VALUES ("1003", "103");
INSERT INTO "Documents" VALUES ("1004", "104");
INSERT INTO "Documents" VALUES ("1005", "105");
INSERT INTO "Documents" VALUES ("1006", "106");
INSERT INTO "Documents" VALUES ("1007", "101");
INSERT INTO "Documents" VALUES ("1008", "103");
INSERT INTO "Documents" VALUES ("1009", "105");
INSERT INTO "Documents" VALUES ("1010", "104");