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





INSERT INTO "Documents" VALUES ("1", "Project Plan");
INSERT INTO "Documents" VALUES ("2", "Budget Report");
INSERT INTO "Documents" VALUES ("3", "Marketing Strategy");
INSERT INTO "Documents" VALUES ("4", "Sales Presentation");
INSERT INTO "Documents" VALUES ("5", "Annual Review");
INSERT INTO "Ref_Template_Types" VALUES ("PRES", "Presentation");
INSERT INTO "Ref_Template_Types" VALUES ("DOC", "Document");
INSERT INTO "Ref_Template_Types" VALUES ("REP", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("INV", "Invoice");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Memorandum");
INSERT INTO "Templates" VALUES ("101", "1", "PRES");
INSERT INTO "Templates" VALUES ("102", "2", "PRES");
INSERT INTO "Templates" VALUES ("103", "1", "DOC");
INSERT INTO "Templates" VALUES ("104", "3", "PRES");
INSERT INTO "Templates" VALUES ("105", "1", "REP");
INSERT INTO "Templates" VALUES ("106", "1", "INV");
INSERT INTO "Templates" VALUES ("107", "2", "MEMO");
INSERT INTO "Templates" VALUES ("108", "1", "PRES");
INSERT INTO "Templates" VALUES ("109", "4", "PRES");
INSERT INTO "Templates" VALUES ("110", "1", "DOC");