
CREATE TABLE "Characteristics" (
	characteristic_id INTEGER, 
	characteristic_type_code VARCHAR(15) NOT NULL, 
	characteristic_data_type VARCHAR(10), 
	characteristic_name VARCHAR(80), 
	other_characteristic_details VARCHAR(255), 
	PRIMARY KEY (characteristic_id), 
	FOREIGN KEY(characteristic_type_code) REFERENCES "Ref_Characteristic_Types" (characteristic_type_code)
)


CREATE TABLE "Product_Characteristics" (
	product_id INTEGER NOT NULL, 
	characteristic_id INTEGER NOT NULL, 
	product_characteristic_value VARCHAR(50), 
	FOREIGN KEY(product_id) REFERENCES "Products" (product_id), 
	FOREIGN KEY(characteristic_id) REFERENCES "Characteristics" (characteristic_id)
)


CREATE TABLE "Products" (
	product_id INTEGER, 
	color_code VARCHAR(15) NOT NULL, 
	product_category_code VARCHAR(15) NOT NULL, 
	product_name VARCHAR(80), 
	typical_buying_price VARCHAR(20), 
	typical_selling_price VARCHAR(20), 
	product_description VARCHAR(255), 
	other_product_details VARCHAR(255), 
	PRIMARY KEY (product_id), 
	FOREIGN KEY(color_code) REFERENCES "Ref_Colors" (color_code), 
	FOREIGN KEY(product_category_code) REFERENCES "Ref_Product_Categories" (product_category_code)
)


CREATE TABLE "Ref_Characteristic_Types" (
	characteristic_type_code VARCHAR(15), 
	characteristic_type_description VARCHAR(80), 
	PRIMARY KEY (characteristic_type_code)
)


CREATE TABLE "Ref_Colors" (
	color_code VARCHAR(15), 
	color_description VARCHAR(80), 
	PRIMARY KEY (color_code)
)


CREATE TABLE "Ref_Product_Categories" (
	product_category_code VARCHAR(15), 
	product_category_description VARCHAR(80), 
	unit_of_measure VARCHAR(20), 
	PRIMARY KEY (product_category_code)
)

CREATE TABLE "Characteristics" (
	characteristic_id INTEGER, 
	characteristic_type_code VARCHAR(15) NOT NULL, 
	characteristic_data_type VARCHAR(10), 
	characteristic_name VARCHAR(80), 
	other_characteristic_details VARCHAR(255), 
	PRIMARY KEY (characteristic_id), 
	FOREIGN KEY(characteristic_type_code) REFERENCES "Ref_Characteristic_Types" (characteristic_type_code)
)

/*
2 rows from Characteristics table:
characteristic_id	characteristic_type_code	characteristic_data_type	characteristic_name	other_characteristic_details
1	Grade	numquam	slow	None
2	Grade	doloribus	fast	None
*/


CREATE TABLE "Product_Characteristics" (
	product_id INTEGER NOT NULL, 
	characteristic_id INTEGER NOT NULL, 
	product_characteristic_value VARCHAR(50), 
	FOREIGN KEY(product_id) REFERENCES "Products" (product_id), 
	FOREIGN KEY(characteristic_id) REFERENCES "Characteristics" (characteristic_id)
)

/*
2 rows from Product_Characteristics table:
product_id	characteristic_id	product_characteristic_value
13	13	low
11	2	low
*/


CREATE TABLE "Products" (
	product_id INTEGER, 
	color_code VARCHAR(15) NOT NULL, 
	product_category_code VARCHAR(15) NOT NULL, 
	product_name VARCHAR(80), 
	typical_buying_price VARCHAR(20), 
	typical_selling_price VARCHAR(20), 
	product_description VARCHAR(255), 
	other_product_details VARCHAR(255), 
	PRIMARY KEY (product_id), 
	FOREIGN KEY(color_code) REFERENCES "Ref_Colors" (color_code), 
	FOREIGN KEY(product_category_code) REFERENCES "Ref_Product_Categories" (product_category_code)
)

/*
2 rows from Products table:
product_id	color_code	product_category_code	product_name	typical_buying_price	typical_selling_price	product_description	other_product_details
1	4	Spices	cumin		2878.3	et	None
2	2	Spices	peper	352447.2874677	1892070.2803543	rerum	None
*/


CREATE TABLE "Ref_Characteristic_Types" (
	characteristic_type_code VARCHAR(15), 
	characteristic_type_description VARCHAR(80), 
	PRIMARY KEY (characteristic_type_code)
)

/*
2 rows from Ref_Characteristic_Types table:
characteristic_type_code	characteristic_type_description
Grade	Grade
Purity	Purity
*/


CREATE TABLE "Ref_Colors" (
	color_code VARCHAR(15), 
	color_description VARCHAR(80), 
	PRIMARY KEY (color_code)
)

/*
2 rows from Ref_Colors table:
color_code	color_description
9	red
5	green
*/


CREATE TABLE "Ref_Product_Categories" (
	product_category_code VARCHAR(15), 
	product_category_description VARCHAR(80), 
	unit_of_measure VARCHAR(20), 
	PRIMARY KEY (product_category_code)
)

/*
2 rows from Ref_Product_Categories table:
product_category_code	product_category_description	unit_of_measure
Herbs	Herbs	Handful             
Seeds	Seeds	Weight - pound,kilo.
*/
What is the characteristic name used by most number of the products?
SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id  =  t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id  =  t3.characteristic_id GROUP BY t3.characteristic_name ORDER BY count(*) DESC LIMIT 1
[{'characteristic_name': 'fast'}]