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 UNIQUE,
"Document_Name" VARCHAR(255),
PRIMARY KEY ("Document_ID")
);

CREATE TABLE "Paragraphs" (
"Paragraph_ID" INT,
"Document_ID" INT,
PRIMARY KEY ("Paragraph_ID"),
FOREIGN KEY ("Document_ID") REFERENCES "Documents"("Document_ID")
);

CREATE TABLE "Ref_Template_Types" (
"Template_Type_Code" CHAR(15),
"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", "Employee Handbook");
INSERT INTO "Documents" VALUES ("2", "Safety Guidelines");
INSERT INTO "Documents" VALUES ("3", "Project Plan");
INSERT INTO "Documents" VALUES ("4", "Empty Document");
INSERT INTO "Documents" VALUES ("5", "Annual Report");
INSERT INTO "Documents" VALUES ("6", "User Manual");
INSERT INTO "Paragraphs" VALUES ("101", "1");
INSERT INTO "Paragraphs" VALUES ("102", "1");
INSERT INTO "Paragraphs" VALUES ("103", "1");
INSERT INTO "Paragraphs" VALUES ("104", "2");
INSERT INTO "Paragraphs" VALUES ("105", "2");
INSERT INTO "Paragraphs" VALUES ("106", "3");
INSERT INTO "Paragraphs" VALUES ("107", "3");
INSERT INTO "Paragraphs" VALUES ("108", "3");
INSERT INTO "Paragraphs" VALUES ("109", "3");
INSERT INTO "Paragraphs" VALUES ("110", "5");
INSERT INTO "Paragraphs" VALUES ("111", "5");
INSERT INTO "Paragraphs" VALUES ("112", "5");
INSERT INTO "Paragraphs" VALUES ("113", "5");
INSERT INTO "Paragraphs" VALUES ("114", "5");
INSERT INTO "Paragraphs" VALUES ("115", "6");
INSERT INTO "Ref_Template_Types" VALUES ("T001", "Legal");
INSERT INTO "Ref_Template_Types" VALUES ("T002", "Technical");
INSERT INTO "Ref_Template_Types" VALUES ("T003", "Marketing");
INSERT INTO "Templates" VALUES ("201", "T001", "Contract Template");
INSERT INTO "Templates" VALUES ("202", "T002", "User Guide Template");
INSERT INTO "Templates" VALUES ("203", "T003", "Brochure Template");
INSERT INTO "Templates" VALUES ("204", "T002", "Installation Guide Template");
INSERT INTO "Templates" VALUES ("205", "T001", "Policy Template");