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", "Project Proposal");
INSERT INTO "Documents" VALUES ("3", "Annual Report");
INSERT INTO "Documents" VALUES ("4", "Marketing Plan");
INSERT INTO "Documents" VALUES ("5", "Technical Specification");
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 ("106", "1");
INSERT INTO "Paragraphs" VALUES ("107", "1");
INSERT INTO "Paragraphs" VALUES ("108", "1");
INSERT INTO "Paragraphs" VALUES ("109", "1");
INSERT INTO "Paragraphs" VALUES ("110", "1");
INSERT INTO "Paragraphs" VALUES ("201", "2");
INSERT INTO "Paragraphs" VALUES ("202", "2");
INSERT INTO "Paragraphs" VALUES ("203", "2");
INSERT INTO "Paragraphs" VALUES ("204", "2");
INSERT INTO "Paragraphs" VALUES ("301", "3");
INSERT INTO "Paragraphs" VALUES ("302", "3");
INSERT INTO "Paragraphs" VALUES ("303", "3");
INSERT INTO "Paragraphs" VALUES ("304", "3");
INSERT INTO "Paragraphs" VALUES ("305", "3");
INSERT INTO "Paragraphs" VALUES ("306", "3");
INSERT INTO "Paragraphs" VALUES ("401", "4");
INSERT INTO "Paragraphs" VALUES ("402", "4");
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 ("507", "5");
INSERT INTO "Paragraphs" VALUES ("508", "5");
INSERT INTO "Paragraphs" VALUES ("509", "5");
INSERT INTO "Ref_Template_Types" VALUES ("TT001", "Legal");
INSERT INTO "Ref_Template_Types" VALUES ("TT002", "Technical");
INSERT INTO "Ref_Template_Types" VALUES ("TT003", "Marketing");
INSERT INTO "Ref_Template_Types" VALUES ("TT004", "Financial");
INSERT INTO "Templates" VALUES ("1001", "TT001", "NDA Agreement Template");
INSERT INTO "Templates" VALUES ("1002", "TT002", "Software Design Template");
INSERT INTO "Templates" VALUES ("1003", "TT003", "Campaign Plan Template");
INSERT INTO "Templates" VALUES ("1004", "TT004", "Budget Report Template");
INSERT INTO "Templates" VALUES ("1005", "TT002", "API Documentation Template");