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,
"Template_ID" INT,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY ("Template_ID") REFERENCES "Templates"("Template_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) UNIQUE,
"Template_Type_Description" VARCHAR(255),
PRIMARY KEY ("Template_Type_Code")
);

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"Template_Type_Code" CHAR(15),
PRIMARY KEY ("Template_ID"),
FOREIGN KEY ("Template_Type_Code") REFERENCES "Ref_Template_Types"("Template_Type_Code")
);





INSERT INTO "Ref_Template_Types" VALUES ("BK", "Book Template");
INSERT INTO "Ref_Template_Types" VALUES ("RP", "Report Template");
INSERT INTO "Ref_Template_Types" VALUES ("LT", "Letter Template");
INSERT INTO "Ref_Template_Types" VALUES ("PR", "Presentation Template");
INSERT INTO "Ref_Template_Types" VALUES ("CV", "Curriculum Vitae Template");
INSERT INTO "Templates" VALUES ("101", "BK");
INSERT INTO "Templates" VALUES ("102", "RP");
INSERT INTO "Templates" VALUES ("103", "LT");
INSERT INTO "Templates" VALUES ("104", "BK");
INSERT INTO "Templates" VALUES ("105", "PR");
INSERT INTO "Templates" VALUES ("106", "RP");
INSERT INTO "Templates" VALUES ("107", "BK");
INSERT INTO "Documents" VALUES ("1", "101", "My First Novel", "A thrilling adventure story.");
INSERT INTO "Documents" VALUES ("2", "102", "Annual Report 2023", "Summary of company performance.");
INSERT INTO "Documents" VALUES ("3", "103", "Job Application Letter", "Application for Software Engineer position.");
INSERT INTO "Documents" VALUES ("4", "104", "Cookbook Recipes", "Collection of family recipes.");
INSERT INTO "Documents" VALUES ("5", "105", "Project Proposal", "Proposal for new software development.");
INSERT INTO "Documents" VALUES ("6", "101", "Sci-Fi Saga Part 1", "The beginning of an epic space opera.");
INSERT INTO "Documents" VALUES ("7", "106", "Quarterly Financials", "Financial results for Q1.");
INSERT INTO "Documents" VALUES ("8", "107", "Poetry Collection", "A compilation of modern poems.");
INSERT INTO "Documents" VALUES ("9", "103", "Follow-up Email", "Follow-up regarding previous meeting.");
INSERT INTO "Documents" VALUES ("10", "102", "Market Analysis", "Analysis of current market trends.");
INSERT INTO "Paragraphs" VALUES ("1", "1");
INSERT INTO "Paragraphs" VALUES ("2", "1");
INSERT INTO "Paragraphs" VALUES ("3", "2");
INSERT INTO "Paragraphs" VALUES ("4", "3");
INSERT INTO "Paragraphs" VALUES ("5", "4");
INSERT INTO "Paragraphs" VALUES ("6", "4");
INSERT INTO "Paragraphs" VALUES ("7", "5");
INSERT INTO "Paragraphs" VALUES ("8", "6");
INSERT INTO "Paragraphs" VALUES ("9", "6");
INSERT INTO "Paragraphs" VALUES ("10", "7");
INSERT INTO "Paragraphs" VALUES ("11", "8");
INSERT INTO "Paragraphs" VALUES ("12", "8");
INSERT INTO "Paragraphs" VALUES ("13", "9");
INSERT INTO "Paragraphs" VALUES ("14", "10");