
CREATE TABLE "Documents" (
	"Document_ID" INTEGER NOT NULL, 
	"Template_ID" INTEGER, 
	"Document_Name" VARCHAR(255), 
	"Document_Description" VARCHAR(255), 
	"Other_Details" VARCHAR(255), 
	PRIMARY KEY ("Document_ID"), 
	FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID")
)


CREATE TABLE "Paragraphs" (
	"Paragraph_ID" INTEGER NOT NULL, 
	"Document_ID" INTEGER NOT NULL, 
	"Paragraph_Text" VARCHAR(255), 
	"Other_Details" VARCHAR(255), 
	PRIMARY KEY ("Paragraph_ID"), 
	FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)


CREATE TABLE "Ref_Template_Types" (
	"Template_Type_Code" CHAR(15) NOT NULL, 
	"Template_Type_Description" VARCHAR(255) NOT NULL, 
	PRIMARY KEY ("Template_Type_Code")
)


CREATE TABLE "Templates" (
	"Template_ID" INTEGER NOT NULL, 
	"Version_Number" INTEGER NOT NULL, 
	"Template_Type_Code" CHAR(15) NOT NULL, 
	"Date_Effective_From" DATETIME, 
	"Date_Effective_To" DATETIME, 
	"Template_Details" VARCHAR(255) NOT NULL, 
	PRIMARY KEY ("Template_ID"), 
	FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code")
)

CREATE TABLE "Documents" (
	"Document_ID" INTEGER NOT NULL, 
	"Template_ID" INTEGER, 
	"Document_Name" VARCHAR(255), 
	"Document_Description" VARCHAR(255), 
	"Other_Details" VARCHAR(255), 
	PRIMARY KEY ("Document_ID"), 
	FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID")
)

/*
2 rows from Documents table:
Document_ID	Template_ID	Document_Name	Document_Description	Other_Details
0	7	Introduction of OS	n	None
1	25	Understanding DB	y	None
*/


CREATE TABLE "Paragraphs" (
	"Paragraph_ID" INTEGER NOT NULL, 
	"Document_ID" INTEGER NOT NULL, 
	"Paragraph_Text" VARCHAR(255), 
	"Other_Details" VARCHAR(255), 
	PRIMARY KEY ("Paragraph_ID"), 
	FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)

/*
2 rows from Paragraphs table:
Paragraph_ID	Document_ID	Paragraph_Text	Other_Details
7	2394	Korea	None
9	3	Somalia	None
*/


CREATE TABLE "Ref_Template_Types" (
	"Template_Type_Code" CHAR(15) NOT NULL, 
	"Template_Type_Description" VARCHAR(255) NOT NULL, 
	PRIMARY KEY ("Template_Type_Code")
)

/*
2 rows from Ref_Template_Types table:
Template_Type_Code	Template_Type_Description
PPT	Presentation
CV	CV
*/


CREATE TABLE "Templates" (
	"Template_ID" INTEGER NOT NULL, 
	"Version_Number" INTEGER NOT NULL, 
	"Template_Type_Code" CHAR(15) NOT NULL, 
	"Date_Effective_From" DATETIME, 
	"Date_Effective_To" DATETIME, 
	"Template_Details" VARCHAR(255) NOT NULL, 
	PRIMARY KEY ("Template_ID"), 
	FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code")
)

/*
2 rows from Templates table:
Template_ID	Version_Number	Template_Type_Code	Date_Effective_From	Date_Effective_To	Template_Details
0	5	PP	2005-11-12 07:09:48	2008-01-05 14:19:28	
1	9	PP	2010-09-24 01:15:11	1999-07-08 03:31:04	
*/
Return the ids of templates that have the code PP or PPT.
SELECT template_id FROM Templates WHERE template_type_code  =  "PP" OR template_type_code  =  "PPT"
[{'Template_ID': 0}, {'Template_ID': 1}, {'Template_ID': 6}, {'Template_ID': 7}, {'Template_ID': 10}, {'Template_ID': 18}, {'Template_ID': 22}, {'Template_ID': 24}, {'Template_ID': 25}]