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_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,
"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 "Documents" VALUES ("1", "User manual for software");
INSERT INTO "Documents" VALUES ("2", "Annual financial report");
INSERT INTO "Documents" VALUES ("3", "Book on modern art");
INSERT INTO "Documents" VALUES ("4", "Research paper on AI");
INSERT INTO "Documents" VALUES ("5", "Book on history of science");
INSERT INTO "Ref_Template_Types" VALUES ("Book", "Book");
INSERT INTO "Ref_Template_Types" VALUES ("MANUAL", "Manual");
INSERT INTO "Ref_Template_Types" VALUES ("REPORT", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("PAPER", "Research Paper");
INSERT INTO "Templates" VALUES ("101", "Book", "Template for fiction books");
INSERT INTO "Templates" VALUES ("102", "Book", "Template for non-fiction books");
INSERT INTO "Templates" VALUES ("103", "MANUAL", "Template for user manuals");
INSERT INTO "Templates" VALUES ("104", "REPORT", "Template for financial reports");
INSERT INTO "Templates" VALUES ("105", "PAPER", "Template for academic papers");