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 "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,
"Version_Number" 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", "NDA Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_C", "Invoice Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_D", "Employment Agreement Template");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE_E", "Marketing Brochure Template");
INSERT INTO "Templates" VALUES ("1", "1", "TYPE_A", "Standard Contract v1 details");
INSERT INTO "Templates" VALUES ("2", "2", "TYPE_A", "Standard Contract v2 details");
INSERT INTO "Templates" VALUES ("3", "1", "TYPE_B", "NDA v1 details");
INSERT INTO "Templates" VALUES ("4", "1", "TYPE_C", "Invoice v1 details");
INSERT INTO "Templates" VALUES ("5", "2", "TYPE_C", "Invoice v2 details");
INSERT INTO "Templates" VALUES ("6", "3", "TYPE_C", "Invoice v3 details");
INSERT INTO "Templates" VALUES ("7", "1", "TYPE_D", "Employment Agreement v1 details");
INSERT INTO "Templates" VALUES ("8", "1", "TYPE_E", "Marketing Brochure v1 details");
INSERT INTO "Templates" VALUES ("9", "2", "TYPE_E", "Marketing Brochure v2 details");
INSERT INTO "Templates" VALUES ("10", "3", "TYPE_E", "Marketing Brochure v3 details");
INSERT INTO "Templates" VALUES ("11", "4", "TYPE_E", "Marketing Brochure v4 details");