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),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY ("Template_ID") REFERENCES "Templates"("Template_ID")
);

CREATE TABLE "Paragraphs" (
"Paragraph_ID" INT,
"Paragraph_Text" VARCHAR(255),
PRIMARY KEY ("Paragraph_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 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 ("PPT", "PowerPoint Presentation Template");
INSERT INTO "Ref_Template_Types" VALUES ("DOC", "Word Document Template");
INSERT INTO "Ref_Template_Types" VALUES ("XLS", "Excel Spreadsheet Template");
INSERT INTO "Ref_Template_Types" VALUES ("PDF", "PDF Document Template");
INSERT INTO "Templates" VALUES ("1", "PPT");
INSERT INTO "Templates" VALUES ("2", "DOC");
INSERT INTO "Templates" VALUES ("3", "PPT");
INSERT INTO "Templates" VALUES ("4", "XLS");
INSERT INTO "Templates" VALUES ("5", "PDF");
INSERT INTO "Documents" VALUES ("101", "1", "Quarterly Results Presentation");
INSERT INTO "Documents" VALUES ("102", "1", "Annual Sales Overview");
INSERT INTO "Documents" VALUES ("103", "2", "Employee Handbook");
INSERT INTO "Documents" VALUES ("104", "3", "Marketing Strategy Slides");
INSERT INTO "Documents" VALUES ("105", "4", "Budget Spreadsheet");
INSERT INTO "Documents" VALUES ("106", "5", "Product Catalog");
INSERT INTO "Documents" VALUES ("107", "3", "Project Timeline Presentation");
INSERT INTO "Documents" VALUES ("108", "2", "Company Policies");
INSERT INTO "Documents" VALUES ("109", "1", "Investor Pitch Deck");
INSERT INTO "Documents" VALUES ("110", "4", "Financial Forecast");
INSERT INTO "Paragraphs" VALUES ("201", "Introduction to the topic");
INSERT INTO "Paragraphs" VALUES ("202", "Summary of key points");
INSERT INTO "Paragraphs" VALUES ("203", "Detailed analysis");
INSERT INTO "Paragraphs" VALUES ("204", "Conclusion and next steps");
INSERT INTO "Paragraphs" VALUES ("205", "Appendix and references");