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,
"Document_ID" INT,
"Paragraph_Text" VARCHAR(255),
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_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Ref_Template_Types" VALUES ("T001", "Customer Feedback Forms");
INSERT INTO "Ref_Template_Types" VALUES ("T002", "Internal Reports");
INSERT INTO "Ref_Template_Types" VALUES ("T003", "Legal Documents");
INSERT INTO "Ref_Template_Types" VALUES ("T004", "Marketing Materials");
INSERT INTO "Templates" VALUES ("1", "Template for customer reviews and feedback collection");
INSERT INTO "Templates" VALUES ("2", "Template for quarterly internal performance reports");
INSERT INTO "Templates" VALUES ("3", "Template for contract agreements and legal notices");
INSERT INTO "Templates" VALUES ("4", "Template for promotional flyers and brochures");
INSERT INTO "Documents" VALUES ("101", "1", "Customer reviews");
INSERT INTO "Documents" VALUES ("102", "2", "Q1 Performance Report");
INSERT INTO "Documents" VALUES ("103", "3", "Service Agreement");
INSERT INTO "Documents" VALUES ("104", "1", "Customer reviews - VIP clients");
INSERT INTO "Documents" VALUES ("105", "4", "Summer Sale Flyer");
INSERT INTO "Paragraphs" VALUES ("1001", "101", "Overall customer satisfaction has improved by 15% this quarter.");
INSERT INTO "Paragraphs" VALUES ("1002", "101", "Most customers appreciate the new user interface.");
INSERT INTO "Paragraphs" VALUES ("1003", "101", "Some customers reported delays in delivery times.");
INSERT INTO "Paragraphs" VALUES ("1004", "104", "VIP clients have expressed high satisfaction with personalized support.");
INSERT INTO "Paragraphs" VALUES ("1005", "104", "VIP clients suggest adding more exclusive offers.");
INSERT INTO "Paragraphs" VALUES ("1006", "102", "The sales team exceeded their targets by 10%.");
INSERT INTO "Paragraphs" VALUES ("1007", "103", "The contract terms have been updated to include new compliance requirements.");
INSERT INTO "Paragraphs" VALUES ("1008", "105", "Our summer sale offers discounts up to 50% on selected items.");
INSERT INTO "Paragraphs" VALUES ("1009", "101", "Customer reviews indicate a need for improved mobile app performance.");