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,
"Version_Number" INT,
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Ref_Template_Types" VALUES ("AD", "Advertisement Template");
INSERT INTO "Ref_Template_Types" VALUES ("IN", "Invoice Template");
INSERT INTO "Ref_Template_Types" VALUES ("CN", "Contract Template");
INSERT INTO "Ref_Template_Types" VALUES ("RP", "Report Template");
INSERT INTO "Ref_Template_Types" VALUES ("MT", "Meeting Template");
INSERT INTO "Templates" VALUES ("1", "1", "Basic Advertisement Template");
INSERT INTO "Templates" VALUES ("2", "2", "Standard Invoice Template");
INSERT INTO "Templates" VALUES ("3", "1", "Contract Template v1");
INSERT INTO "Templates" VALUES ("4", "3", "Advanced Advertisement Template");
INSERT INTO "Templates" VALUES ("5", "1", "Monthly Report Template");
INSERT INTO "Documents" VALUES ("101", "1");
INSERT INTO "Documents" VALUES ("102", "4");
INSERT INTO "Documents" VALUES ("103", "2");
INSERT INTO "Documents" VALUES ("104", "3");
INSERT INTO "Documents" VALUES ("105", "5");