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,
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 ("TYPE001", "Country Reports");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE002", "Travel Guides");
INSERT INTO "Ref_Template_Types" VALUES ("TYPE003", "Sports Summaries");
INSERT INTO "Templates" VALUES ("1", "Annual Country Overview");
INSERT INTO "Templates" VALUES ("2", "World Cup Highlights");
INSERT INTO "Templates" VALUES ("3", "Travel Itineraries");
INSERT INTO "Documents" VALUES ("101", "1");
INSERT INTO "Documents" VALUES ("102", "2");
INSERT INTO "Documents" VALUES ("103", "3");
INSERT INTO "Documents" VALUES ("104", "1");
INSERT INTO "Paragraphs" VALUES ("1001", "101", "Brazil");
INSERT INTO "Paragraphs" VALUES ("1002", "101", "Argentina");
INSERT INTO "Paragraphs" VALUES ("1003", "102", "Ireland");
INSERT INTO "Paragraphs" VALUES ("1004", "102", "Brazil");
INSERT INTO "Paragraphs" VALUES ("1005", "103", "France");
INSERT INTO "Paragraphs" VALUES ("1006", "103", "Germany");
INSERT INTO "Paragraphs" VALUES ("1007", "104", "Brazil");
INSERT INTO "Paragraphs" VALUES ("1008", "104", "Ireland");
INSERT INTO "Paragraphs" VALUES ("1009", "104", "Portugal");