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", "Marketing Strategy");
INSERT INTO "Documents" VALUES ("7", "User Manual");
INSERT INTO "Documents" VALUES ("8", "Multiple Max Paragraphs Doc A");
INSERT INTO "Documents" VALUES ("9", "Multiple Max Paragraphs Doc B");
INSERT INTO "Paragraphs" VALUES ("101", "1");
INSERT INTO "Paragraphs" VALUES ("102", "1");
INSERT INTO "Paragraphs" VALUES ("103", "1");
INSERT INTO "Paragraphs" VALUES ("104", "1");
INSERT INTO "Paragraphs" VALUES ("105", "1");
INSERT INTO "Paragraphs" VALUES ("201", "2");
INSERT INTO "Paragraphs" VALUES ("202", "2");
INSERT INTO "Paragraphs" VALUES ("301", "3");
INSERT INTO "Paragraphs" VALUES ("302", "3");
INSERT INTO "Paragraphs" VALUES ("303", "3");
INSERT INTO "Paragraphs" VALUES ("501", "5");
INSERT INTO "Paragraphs" VALUES ("502", "5");
INSERT INTO "Paragraphs" VALUES ("503", "5");
INSERT INTO "Paragraphs" VALUES ("504", "5");
INSERT INTO "Paragraphs" VALUES ("505", "5");
INSERT INTO "Paragraphs" VALUES ("506", "5");
INSERT INTO "Paragraphs" VALUES ("601", "6");
INSERT INTO "Paragraphs" VALUES ("602", "6");
INSERT INTO "Paragraphs" VALUES ("603", "6");
INSERT INTO "Paragraphs" VALUES ("604", "6");
INSERT INTO "Paragraphs" VALUES ("701", "7");
INSERT INTO "Paragraphs" VALUES ("801", "8");
INSERT INTO "Paragraphs" VALUES ("802", "8");
INSERT INTO "Paragraphs" VALUES ("803", "8");
INSERT INTO "Paragraphs" VALUES ("804", "8");
INSERT INTO "Paragraphs" VALUES ("805", "8");
INSERT INTO "Paragraphs" VALUES ("806", "8");
INSERT INTO "Paragraphs" VALUES ("901", "9");
INSERT INTO "Paragraphs" VALUES ("902", "9");
INSERT INTO "Paragraphs" VALUES ("903", "9");
INSERT INTO "Paragraphs" VALUES ("904", "9");
INSERT INTO "Paragraphs" VALUES ("905", "9");
INSERT INTO "Paragraphs" VALUES ("906", "9");
INSERT INTO "Ref_Template_Types" VALUES ("TT01", "Legal");
INSERT INTO "Ref_Template_Types" VALUES ("TT02", "Technical");
INSERT INTO "Ref_Template_Types" VALUES ("TT03", "Marketing");
INSERT INTO "Templates" VALUES ("1", "TT01", "Confidentiality Clause");
INSERT INTO "Templates" VALUES ("2", "TT02", "System Architecture Overview");
INSERT INTO "Templates" VALUES ("3", "TT03", "Campaign Plan Outline");