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) UNIQUE,
"Template_Type_Description" VARCHAR(255),
PRIMARY KEY ("Template_Type_Code")
);

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"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 "Ref_Template_Types" VALUES ("PPT", "PowerPoint Presentation");
INSERT INTO "Ref_Template_Types" VALUES ("DOC", "Word Document");
INSERT INTO "Ref_Template_Types" VALUES ("XLS", "Excel Spreadsheet");
INSERT INTO "Ref_Template_Types" VALUES ("PDF", "PDF Document");
INSERT INTO "Ref_Template_Types" VALUES ("HTML", "HTML Template");
INSERT INTO "Templates" VALUES ("1", "PPT", "Corporate Presentation Template");
INSERT INTO "Templates" VALUES ("2", "DOC", "Legal Document Template");
INSERT INTO "Templates" VALUES ("3", "PPT", "Marketing Presentation Template");
INSERT INTO "Templates" VALUES ("4", "XLS", "Financial Report Template");
INSERT INTO "Templates" VALUES ("5", "PDF", "Invoice Template");
INSERT INTO "Templates" VALUES ("6", "PPT", "Training Presentation Template");
INSERT INTO "Templates" VALUES ("7", "HTML", "Webpage Template");
INSERT INTO "Documents" VALUES ("101", "1", "Q1 Sales Presentation");
INSERT INTO "Documents" VALUES ("102", "2", "Contract Agreement");
INSERT INTO "Documents" VALUES ("103", "3", "Product Launch Deck");
INSERT INTO "Documents" VALUES ("104", "4", "Annual Financials");
INSERT INTO "Documents" VALUES ("105", "5", "Customer Invoice");
INSERT INTO "Documents" VALUES ("106", "6", "Employee Training Slides");
INSERT INTO "Documents" VALUES ("107", "7", "Homepage Design");
INSERT INTO "Documents" VALUES ("108", "1", "Board Meeting Presentation");
INSERT INTO "Documents" VALUES ("109", "3", "Marketing Strategy Presentation");
INSERT INTO "Documents" VALUES ("110", "6", "Safety Training Presentation");
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 and data");
INSERT INTO "Paragraphs" VALUES ("204", "Conclusion and next steps");
INSERT INTO "Paragraphs" VALUES ("205", "Appendix and references");