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 "Paragraphs" VALUES ("101", "1");
INSERT INTO "Paragraphs" VALUES ("102", "1");
INSERT INTO "Paragraphs" VALUES ("103", "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", "5");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE001", "Legal");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE002", "Technical");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE003", "Financial");
INSERT INTO "Templates" VALUES ("1", "TYPE001", "Confidentiality Clause");
INSERT INTO "Templates" VALUES ("2", "TYPE002", "System Architecture Overview");
INSERT INTO "Templates" VALUES ("3", "TYPE003", "Budget Summary");
INSERT INTO "Templates" VALUES ("4", "TYPE001", "Terms and Conditions");
INSERT INTO "Templates" VALUES ("5", "TYPE002", "Safety Procedures");