
CREATE TABLE "Breeds" (
	breed_code VARCHAR(10), 
	breed_name VARCHAR(80), 
	PRIMARY KEY (breed_code)
)


CREATE TABLE "Charges" (
	charge_id INTEGER, 
	charge_type VARCHAR(10), 
	charge_amount DECIMAL(19, 4), 
	PRIMARY KEY (charge_id)
)


CREATE TABLE "Dogs" (
	dog_id INTEGER, 
	owner_id INTEGER NOT NULL, 
	abandoned_yn VARCHAR(1), 
	breed_code VARCHAR(10) NOT NULL, 
	size_code VARCHAR(10) NOT NULL, 
	name VARCHAR(50), 
	age VARCHAR(20), 
	date_of_birth DATETIME, 
	gender VARCHAR(1), 
	weight VARCHAR(20), 
	date_arrived DATETIME, 
	date_adopted DATETIME, 
	date_departed DATETIME, 
	PRIMARY KEY (dog_id), 
	FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), 
	FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), 
	FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code)
)


CREATE TABLE "Owners" (
	owner_id INTEGER, 
	first_name VARCHAR(50), 
	last_name VARCHAR(50), 
	street VARCHAR(50), 
	city VARCHAR(50), 
	state VARCHAR(20), 
	zip_code VARCHAR(20), 
	email_address VARCHAR(50), 
	home_phone VARCHAR(20), 
	cell_number VARCHAR(20), 
	PRIMARY KEY (owner_id)
)


CREATE TABLE "Professionals" (
	professional_id INTEGER, 
	role_code VARCHAR(10) NOT NULL, 
	first_name VARCHAR(50), 
	street VARCHAR(50), 
	city VARCHAR(50), 
	state VARCHAR(20), 
	zip_code VARCHAR(20), 
	last_name VARCHAR(50), 
	email_address VARCHAR(50), 
	home_phone VARCHAR(20), 
	cell_number VARCHAR(20), 
	PRIMARY KEY (professional_id)
)


CREATE TABLE "Sizes" (
	size_code VARCHAR(10), 
	size_description VARCHAR(80), 
	PRIMARY KEY (size_code)
)


CREATE TABLE "Treatment_Types" (
	treatment_type_code VARCHAR(10), 
	treatment_type_description VARCHAR(80), 
	PRIMARY KEY (treatment_type_code)
)


CREATE TABLE "Treatments" (
	treatment_id INTEGER, 
	dog_id INTEGER NOT NULL, 
	professional_id INTEGER NOT NULL, 
	treatment_type_code VARCHAR(10) NOT NULL, 
	date_of_treatment DATETIME, 
	cost_of_treatment DECIMAL(19, 4), 
	PRIMARY KEY (treatment_id), 
	FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), 
	FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), 
	FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code)
)

CREATE TABLE "Breeds" (
	breed_code VARCHAR(10), 
	breed_name VARCHAR(80), 
	PRIMARY KEY (breed_code)
)

/*
2 rows from Breeds table:
breed_code	breed_name
ESK	Eskimo
HUS	Husky
*/


CREATE TABLE "Charges" (
	charge_id INTEGER, 
	charge_type VARCHAR(10), 
	charge_amount DECIMAL(19, 4), 
	PRIMARY KEY (charge_id)
)

/*
2 rows from Charges table:
charge_id	charge_type	charge_amount
1	Daily Accommodation	98.0000
2	Drugs	322.0000
*/


CREATE TABLE "Dogs" (
	dog_id INTEGER, 
	owner_id INTEGER NOT NULL, 
	abandoned_yn VARCHAR(1), 
	breed_code VARCHAR(10) NOT NULL, 
	size_code VARCHAR(10) NOT NULL, 
	name VARCHAR(50), 
	age VARCHAR(20), 
	date_of_birth DATETIME, 
	gender VARCHAR(1), 
	weight VARCHAR(20), 
	date_arrived DATETIME, 
	date_adopted DATETIME, 
	date_departed DATETIME, 
	PRIMARY KEY (dog_id), 
	FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), 
	FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), 
	FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code)
)

/*
2 rows from Dogs table:
dog_id	owner_id	abandoned_yn	breed_code	size_code	name	age	date_of_birth	gender	weight	date_arrived	date_adopted	date_departed
1	3	1	ESK	LGE	Kacey	6	2012-01-27 05:11:53	1	7.57	2017-09-08 20:10:13	2018-03-06 16:32:11	2018-03-25 06:58:44
2	11	0	BUL	LGE	Hipolito	9	2013-02-13 05:15:21	0	1.72	2017-12-22 05:02:02	2018-03-25 08:12:51	2018-03-25 02:11:32
*/


CREATE TABLE "Owners" (
	owner_id INTEGER, 
	first_name VARCHAR(50), 
	last_name VARCHAR(50), 
	street VARCHAR(50), 
	city VARCHAR(50), 
	state VARCHAR(20), 
	zip_code VARCHAR(20), 
	email_address VARCHAR(50), 
	home_phone VARCHAR(20), 
	cell_number VARCHAR(20), 
	PRIMARY KEY (owner_id)
)

/*
2 rows from Owners table:
owner_id	first_name	last_name	street	city	state	zip_code	email_address	home_phone	cell_number
1	Nora	Haley	0647 Hintz Village Apt. 024	Lake Tia	Wisconsin	93165	lynn81@example.org	1-682-845-0116x63235	478.978.0729
2	Melisa	DuBuque	1204 Mae Highway Apt. 107	Port Reannamouth	Virginia	45244	ykris@example.com	(799)563-0260x454	(722)768-5439x484
*/


CREATE TABLE "Professionals" (
	professional_id INTEGER, 
	role_code VARCHAR(10) NOT NULL, 
	first_name VARCHAR(50), 
	street VARCHAR(50), 
	city VARCHAR(50), 
	state VARCHAR(20), 
	zip_code VARCHAR(20), 
	last_name VARCHAR(50), 
	email_address VARCHAR(50), 
	home_phone VARCHAR(20), 
	cell_number VARCHAR(20), 
	PRIMARY KEY (professional_id)
)

/*
2 rows from Professionals table:
professional_id	role_code	first_name	street	city	state	zip_code	last_name	email_address	home_phone	cell_number
1	Employee	Taryn	6915 Oberbrunner Point Suite 491
Gleasonville, LA 	West Heidi	Indiana	06646	Braun	deanna.schuster@example.com	+71(6)2898266914	(275)939-2435x80863
2	Employee	Jayson	88665 Terence Lodge Apt. 904
Corneliusfort, NC 194	North Odellfurt	Connecticut	43129	Ullrich	lucile.shanahan@example.org	+02(1)0259033559	889-940-2676
*/


CREATE TABLE "Sizes" (
	size_code VARCHAR(10), 
	size_description VARCHAR(80), 
	PRIMARY KEY (size_code)
)

/*
2 rows from Sizes table:
size_code	size_description
SML	Small
MED	Medium
*/


CREATE TABLE "Treatment_Types" (
	treatment_type_code VARCHAR(10), 
	treatment_type_description VARCHAR(80), 
	PRIMARY KEY (treatment_type_code)
)

/*
2 rows from Treatment_Types table:
treatment_type_code	treatment_type_description
EXAM	Physical examination
VAC	Vaccination
*/


CREATE TABLE "Treatments" (
	treatment_id INTEGER, 
	dog_id INTEGER NOT NULL, 
	professional_id INTEGER NOT NULL, 
	treatment_type_code VARCHAR(10) NOT NULL, 
	date_of_treatment DATETIME, 
	cost_of_treatment DECIMAL(19, 4), 
	PRIMARY KEY (treatment_id), 
	FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), 
	FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), 
	FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code)
)

/*
2 rows from Treatments table:
treatment_id	dog_id	professional_id	treatment_type_code	date_of_treatment	cost_of_treatment
1	14	9	WALK	2018-03-19 04:39:54	567.0000
2	4	10	VAC	2018-03-15 20:25:34	147.0000
*/
Give me the description of the treatment type whose total cost is the lowest.
SELECT T1.treatment_type_description FROM Treatment_types AS T1 JOIN Treatments AS T2 ON T1.treatment_type_code  =  T2.treatment_type_code GROUP BY T1.treatment_type_code ORDER BY sum(cost_of_treatment) ASC LIMIT 1
[{'treatment_type_description': 'Take for a Walk'}]