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,
"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),
"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 ("TT001", "Business Report");
INSERT INTO "Ref_Template_Types" VALUES ("TT002", "Technical Manual");
INSERT INTO "Ref_Template_Types" VALUES ("TT003", "Legal Document");
INSERT INTO "Ref_Template_Types" VALUES ("TT004", "Marketing Brochure");
INSERT INTO "Ref_Template_Types" VALUES ("TT005", "Financial Statement");
INSERT INTO "Templates" VALUES ("101", "TT001", "Annual business report template");
INSERT INTO "Templates" VALUES ("102", "TT002", "User guide for software");
INSERT INTO "Templates" VALUES ("103", "TT003", "Contract agreement template");
INSERT INTO "Templates" VALUES ("104", "TT004", "Product marketing brochure");
INSERT INTO "Templates" VALUES ("105", "TT005", "Quarterly financial statement");
INSERT INTO "Documents" VALUES ("201", "101", "Data base");
INSERT INTO "Documents" VALUES ("202", "102", "User Manual");
INSERT INTO "Documents" VALUES ("203", "103", "Service Contract");
INSERT INTO "Documents" VALUES ("204", "104", "New Product Launch");
INSERT INTO "Documents" VALUES ("205", "105", "Q1 Financials");
INSERT INTO "Documents" VALUES ("206", "101", "Company Overview");
INSERT INTO "Documents" VALUES ("207", "103", "Lease Agreement");
INSERT INTO "Paragraphs" VALUES ("301", "This document outlines the annual business performance.");
INSERT INTO "Paragraphs" VALUES ("302", "Step-by-step instructions for software installation.");
INSERT INTO "Paragraphs" VALUES ("303", "Terms and conditions of the contract.");
INSERT INTO "Paragraphs" VALUES ("304", "Highlights of the new product features.");
INSERT INTO "Paragraphs" VALUES ("305", "Summary of financial results for the quarter.");
INSERT INTO "Paragraphs" VALUES ("306", "Company mission and vision statements.");
INSERT INTO "Paragraphs" VALUES ("307", "Legal obligations and responsibilities of parties involved.");