
CREATE TABLE "School" (
	"School_id" TEXT, 
	"School_name" TEXT, 
	"Location" TEXT, 
	"Mascot" TEXT, 
	"Enrollment" INTEGER, 
	"IHSAA_Class" TEXT, 
	"IHSAA_Football_Class" TEXT, 
	"County" TEXT, 
	PRIMARY KEY ("School_id")
)


CREATE TABLE budget (
	"School_id" INTEGER, 
	"Year" INTEGER, 
	"Budgeted" INTEGER, 
	total_budget_percent_budgeted REAL, 
	"Invested" INTEGER, 
	total_budget_percent_invested REAL, 
	"Budget_invested_percent" TEXT, 
	PRIMARY KEY ("School_id", "Year"), 
	FOREIGN KEY("School_id") REFERENCES "School" ("School_id")
)


CREATE TABLE endowment (
	endowment_id INTEGER, 
	"School_id" INTEGER, 
	donator_name TEXT, 
	amount REAL, 
	PRIMARY KEY (endowment_id), 
	FOREIGN KEY("School_id") REFERENCES "School" ("School_id")
)

CREATE TABLE "School" (
	"School_id" TEXT, 
	"School_name" TEXT, 
	"Location" TEXT, 
	"Mascot" TEXT, 
	"Enrollment" INTEGER, 
	"IHSAA_Class" TEXT, 
	"IHSAA_Football_Class" TEXT, 
	"County" TEXT, 
	PRIMARY KEY ("School_id")
)

/*
2 rows from School table:
School_id	School_name	Location	Mascot	Enrollment	IHSAA_Class	IHSAA_Football_Class	County
1	Bremen	Bremen	Lions	495	AA	AA	50 Marshall
2	Culver Community	Culver	Cavaliers	287	A	A	50 Marshall
*/


CREATE TABLE budget (
	"School_id" INTEGER, 
	"Year" INTEGER, 
	"Budgeted" INTEGER, 
	total_budget_percent_budgeted REAL, 
	"Invested" INTEGER, 
	total_budget_percent_invested REAL, 
	"Budget_invested_percent" TEXT, 
	PRIMARY KEY ("School_id", "Year"), 
	FOREIGN KEY("School_id") REFERENCES "School" ("School_id")
)

/*
2 rows from budget table:
School_id	Year	Budgeted	total_budget_percent_budgeted	Invested	total_budget_percent_invested	Budget_invested_percent
2	1999	4979	2.0	2134	2.0	42.9
2	2000	3666	2.0	5840	2.0	159.3
*/


CREATE TABLE endowment (
	endowment_id INTEGER, 
	"School_id" INTEGER, 
	donator_name TEXT, 
	amount REAL, 
	PRIMARY KEY (endowment_id), 
	FOREIGN KEY("School_id") REFERENCES "School" ("School_id")
)

/*
2 rows from endowment table:
endowment_id	School_id	donator_name	amount
1	1	Monte Plata	9.51
2	2	San José de Ocoa	9.83
*/
List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.
SELECT T1.School_name ,  T1.Mascot ,  T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id  =  T2.school_id WHERE Budgeted  >  6000 OR YEAR  <  2003 ORDER BY T2.total_budget_percent_invested ,  T2.total_budget_percent_budgeted
[{'School_name': 'Culver Community', 'Mascot': 'Cavaliers', 'IHSAA_Football_Class': 'A'}, {'School_name': 'Culver Community', 'Mascot': 'Cavaliers', 'IHSAA_Football_Class': 'A'}, {'School_name': 'Culver Community', 'Mascot': 'Cavaliers', 'IHSAA_Football_Class': 'A'}, {'School_name': 'Glenn', 'Mascot': 'Falcons', 'IHSAA_Football_Class': 'AAA'}, {'School_name': 'Jimtown', 'Mascot': 'Jimmies', 'IHSAA_Football_Class': 'AAA'}, {'School_name': 'Bremen', 'Mascot': 'Lions', 'IHSAA_Football_Class': 'AA'}, {'School_name': 'Knox Community', 'Mascot': 'Redskins', 'IHSAA_Football_Class': 'AAA'}, {'School_name': 'Knox Community', 'Mascot': 'Redskins', 'IHSAA_Football_Class': 'AAA'}]