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),
"Document_Description" 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,
PRIMARY KEY ("Template_ID")
);





INSERT INTO "Ref_Template_Types" VALUES ("CV", "Curriculum Vitae");
INSERT INTO "Ref_Template_Types" VALUES ("INV", "Invoice");
INSERT INTO "Ref_Template_Types" VALUES ("LTR", "Letter");
INSERT INTO "Ref_Template_Types" VALUES ("RPT", "Report");
INSERT INTO "Ref_Template_Types" VALUES ("MEMO", "Memorandum");
INSERT INTO "Templates" VALUES ("101");
INSERT INTO "Templates" VALUES ("102");
INSERT INTO "Templates" VALUES ("103");
INSERT INTO "Templates" VALUES ("104");
INSERT INTO "Templates" VALUES ("105");
INSERT INTO "Templates" VALUES ("106");
INSERT INTO "Documents" VALUES ("1", "101", "Robbin CV", "Detailed CV for job application");
INSERT INTO "Documents" VALUES ("2", "102", "Project Report Q1", "Quarterly report for Project X");
INSERT INTO "Documents" VALUES ("3", "101", "John Doe CV", "Standard CV for general use");
INSERT INTO "Documents" VALUES ("4", "103", "Client Invoice 2023-001", "Invoice for services rendered to Client A");
INSERT INTO "Documents" VALUES ("5", "104", "Meeting Minutes 2023-05-10", "Minutes from the weekly team meeting");
INSERT INTO "Documents" VALUES ("6", "101", "Robbin CV Updated", "Updated CV for Robbin with new experience");
INSERT INTO "Documents" VALUES ("7", "105", "Robbin CV", "Another CV for Robbin, slightly different format");
INSERT INTO "Documents" VALUES ("8", "106", "Robbin CV Draft", "Draft version of Robbins CV");
INSERT INTO "Paragraphs" VALUES ("1", "This is the first paragraph of a document.");
INSERT INTO "Paragraphs" VALUES ("2", "This paragraph contains important information.");
INSERT INTO "Paragraphs" VALUES ("3", "A concluding paragraph for the document.");
INSERT INTO "Paragraphs" VALUES ("4", "Introduction to the report.");
INSERT INTO "Paragraphs" VALUES ("5", "Key findings and recommendations.");