lianghsun/spider-text2sql-bench huggingface dataset:
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Return the unit of measure for 'Herb' products.

### SQL
SELECT unit_of_measure FROM ref_product_categories WHERE product_category_code  =  "Herbs"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Find the product category description of the product category with code "Spices".

### SQL
SELECT product_category_description FROM ref_product_categories WHERE product_category_code  =  "Spices"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the description of the product category with the code 'Spices'?

### SQL
SELECT product_category_description FROM ref_product_categories WHERE product_category_code  =  "Spices"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the product category description and unit of measurement of category "Herbs"?

### SQL
SELECT product_category_description ,  unit_of_measure FROM ref_product_categories WHERE product_category_code  =  "Herbs"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Return the description and unit of measurement for products in the 'Herbs' category.

### SQL
SELECT product_category_description ,  unit_of_measure FROM ref_product_categories WHERE product_category_code  =  "Herbs"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the unit of measurement of product named "cumin"?

### SQL
SELECT t2.unit_of_measure FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code WHERE t1.product_name  =  "cumin"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Give the unit of measure for the product with the name 'cumin'.

### SQL
SELECT t2.unit_of_measure FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code WHERE t1.product_name  =  "cumin"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Find the unit of measurement and product category code of product named "chervil".

### SQL
SELECT t2.unit_of_measure ,  t2.product_category_code FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code WHERE t1.product_name  =  "chervil"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What are the unit of measure and category code for the 'chervil' product?

### SQL
SELECT t2.unit_of_measure ,  t2.product_category_code FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code WHERE t1.product_name  =  "chervil"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Find the product names that are colored 'white' but do not have unit of measurement "Handful".

### SQL
SELECT t1.product_name FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code JOIN ref_colors AS t3 ON t1.color_code  =  t3.color_code WHERE t3.color_description  =  "white" AND t2.unit_of_measure != "Handful"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What are the names of products that are not 'white' in color and are not measured by the unit 'Handful'?

### SQL
SELECT t1.product_name FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code  =  t2.product_category_code JOIN ref_colors AS t3 ON t1.color_code  =  t3.color_code WHERE t3.color_description  =  "white" AND t2.unit_of_measure != "Handful"
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the description of the color for most products?

### SQL
SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) DESC LIMIT 1
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Return the color description that is most common across all products.

### SQL
SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) DESC LIMIT 1
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the description of the color used by least products?

### SQL
SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) ASC LIMIT 1
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Give the color description that is least common across products.

### SQL
SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code  =  t2.color_code GROUP BY t2.color_description ORDER BY count(*) ASC LIMIT 1
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What is the characteristic name used by most number of the products?

### SQL
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
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Return the name of the characteristic that is most common across all products.

### SQL
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
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What are the names, details and data types of the characteristics which are never used by any product?

### SQL
SELECT characteristic_name ,  other_characteristic_details ,  characteristic_data_type FROM CHARACTERISTICS EXCEPT SELECT t1.characteristic_name ,  t1.other_characteristic_details ,  t1.characteristic_data_type FROM CHARACTERISTICS AS t1 JOIN product_characteristics AS t2 ON t1.characteristic_id  =  t2.characteristic_id
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Give the names, details, and data types of characteristics that are not found in any product.

### SQL
SELECT characteristic_name ,  other_characteristic_details ,  characteristic_data_type FROM CHARACTERISTICS EXCEPT SELECT t1.characteristic_name ,  t1.other_characteristic_details ,  t1.characteristic_data_type FROM CHARACTERISTICS AS t1 JOIN product_characteristics AS t2 ON t1.characteristic_id  =  t2.characteristic_id
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
What are characteristic names used at least twice across all products?

### SQL
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 HAVING count(*)  >= 2
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Give the names of characteristics that are in two or more products?

### SQL
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 HAVING count(*)  >= 2
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
How many colors are never used by any product?

### SQL
SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products )
### Database Schema
CREATE TABLE `Ref_Characteristic_Types` (
`characteristic_type_code` VARCHAR(15) PRIMARY KEY,
`characteristic_type_description` VARCHAR(80)
)

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

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

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

CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`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),
FOREIGN KEY (`product_category_code` ) REFERENCES `Ref_Product_Categories`(`product_category_code` ),FOREIGN KEY (`color_code` ) REFERENCES `Ref_Colors`(`color_code` )
)

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

### Question
Count the number of colors that are not used in any products.

### SQL
SELECT count(*) FROM Ref_colors WHERE color_code NOT IN ( SELECT color_code FROM products )
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
How many events are there?

### SQL
SELECT count(*) FROM event
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
List all the event names by year from the most recent to the oldest.

### SQL
SELECT name FROM event ORDER BY YEAR DESC
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
What is the name of the event that happened in the most recent year?

### SQL
SELECT name FROM event ORDER BY YEAR DESC LIMIT 1
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
How many stadiums are there?

### SQL
SELECT count(*) FROM stadium
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
Find the name of the stadium that has the maximum capacity.

### SQL
SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1
### Database Schema
CREATE TABLE "swimmer" (
"ID" int,
"name" text,
"Nationality" text,
"meter_100" real,
"meter_200" text,
"meter_300" text,
"meter_400" text,
"meter_500" text,
"meter_600" text,
"meter_700" text,
"Time" text,
PRIMARY KEY ("ID")
)

CREATE TABLE "stadium" (
"ID" int,
"name" text,
"Capacity" int,
"City" text,
"Country" text,
"Opening_year" int,
PRIMARY KEY ("ID")
)

CREATE TABLE "event" (
"ID" int,
"Name" text,
"Stadium_ID" int,
"Year" text,
PRIMARY KEY ("ID"),
FOREIGN KEY (`Stadium_ID`) REFERENCES `stadium`(`ID`)
)

CREATE TABLE "record" (
"ID" int,
"Result" text,
"Swimmer_ID" int,
"Event_ID" int,
PRIMARY KEY ("Swimmer_ID","Event_ID"),
FOREIGN KEY (`Event_ID`) REFERENCES `event`(`ID`),
FOREIGN KEY (`Swimmer_ID`) REFERENCES `swimmer`(`ID`)
)

### Question
Find the names of stadiums whose capacity is smaller than the average capacity.

### SQL
SELECT name FROM stadium WHERE capacity  <  (SELECT avg(capacity) FROM stadium)