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

CREATE TABLE "Templates" (
"Template_ID" INT UNIQUE,
"Template_Details" VARCHAR(255),
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Templates" VALUES ("1", "Standard Letter Template");
INSERT INTO "Templates" VALUES ("2", "Invoice Template");
INSERT INTO "Templates" VALUES ("3", "Report Template");
INSERT INTO "Templates" VALUES ("4", "Memo Template");
INSERT INTO "Templates" VALUES ("5", "Contract Template");
INSERT INTO "Templates" VALUES ("6", "Meeting Minutes Template");
INSERT INTO "Documents" VALUES ("101", "1", "Letter to Client A");
INSERT INTO "Documents" VALUES ("102", "1", "Letter to Client B");
INSERT INTO "Documents" VALUES ("103", "2", "Invoice #2023-001");
INSERT INTO "Documents" VALUES ("104", "3", "Annual Report 2022");
INSERT INTO "Documents" VALUES ("105", "1", "Letter to Client C");
INSERT INTO "Documents" VALUES ("106", "2", "Invoice #2023-002");
INSERT INTO "Documents" VALUES ("107", "4", "Internal Memo Q3");
INSERT INTO "Documents" VALUES ("108", "5", "Service Agreement v1");
INSERT INTO "Documents" VALUES ("109", "3", "Quarterly Report Q1");
INSERT INTO "Documents" VALUES ("110", "6", "Board Meeting Minutes");
INSERT INTO "Documents" VALUES ("111", "1", "Letter to Client D");
INSERT INTO "Documents" VALUES ("112", "2", "Invoice #2023-003");
INSERT INTO "Documents" VALUES ("113", "4", "Internal Memo Q4");
INSERT INTO "Paragraphs" VALUES ("1001", "101");
INSERT INTO "Paragraphs" VALUES ("1002", "101");
INSERT INTO "Paragraphs" VALUES ("1003", "102");
INSERT INTO "Paragraphs" VALUES ("1004", "103");
INSERT INTO "Paragraphs" VALUES ("1005", "104");
INSERT INTO "Paragraphs" VALUES ("1006", "104");
INSERT INTO "Paragraphs" VALUES ("1007", "104");
INSERT INTO "Paragraphs" VALUES ("1008", "105");
INSERT INTO "Paragraphs" VALUES ("1009", "106");
INSERT INTO "Paragraphs" VALUES ("1010", "107");
INSERT INTO "Paragraphs" VALUES ("1011", "108");
INSERT INTO "Paragraphs" VALUES ("1012", "109");
INSERT INTO "Paragraphs" VALUES ("1013", "110");
INSERT INTO "Paragraphs" VALUES ("1014", "111");
INSERT INTO "Paragraphs" VALUES ("1015", "112");
INSERT INTO "Paragraphs" VALUES ("1016", "113");