-- create product type table CREATE TABLE product_type( protype_id INT PRIMARY KEY AUTO_INCREMENT, protype_name VARCHAR(15) ) SELECT * FROM product_type; INSERT product_type(protype_name)VALUES( ' home appliances ' ); INSERT product_type(protype_name)VALUES( ' Mobile phone number ' ); INSERT product_type(protype_name)VALUES( ' computer office ' ); INSERT product_type(protype_name)VALUES( ' Book audio and video ' ); INSERT product_type(protype_name)VALUES( ' home furniture ' ); INSERT product_type(protype_name)VALUES( ' clothing accessories ' ); INSERT product_type(protype_name)VALUES( ' personal makeup ' ); INSERT product_type(protype_name)VALUES( ' sports outdoor ' ); INSERT product_type(protype_name)VALUES( ' automobile supplies ' ); INSERT product_type(protype_name)VALUES( ' Food and Drink ' ); INSERT product_type(protype_name)VALUES( ' Nutrition and Health ' ); DROP TABLE product; -- create product table CREATE TABLE product( proid INT PRIMARY KEY, pro_name VARCHAR(50), protype_id INT, price INT, pinpai VARCHAR(10), chandi VARCHAR ( 10 ), CONSTRAINT product_product_type_fk FOREIGN KEY (protype_id) REFERENCES product_type(protype_id) ) SELECT * FROM product; INSERT INTO product VALUES( 1 , ' KNOKA 42-inch full HD LCD TV ' , 1 , 1999 , ' Konka ' , ' Shenzhen ' ); INSERT INTO product VALUES( 2 , ' Sony (SONY) 4G mobile phone (black) ' , 2 , 3238 , ' Sony ' , ' Shenzhen ' ); INSERT INTO product VALUES( 3 , ' Hisense 55-inch Smart TV ' , 1 , 4199 , ' Hisense ' , ' Qingdao ' ); INSERT INTO product VALUES( 4 , ' Lenovo 14.0 inch laptop ' , 3 , 5499 , ' Lenovo ' , ' Beijing ' ); INSERT INTO product VALUES( 5 , ' Sony (SONY) 13.3 inch touch ultrabook ' , 3 , 11499 , ' Sony ' , ' Tianjin ' ); INSERT INTO product VALUES( 11 , ' Sony (SONY) 60-inch full HD LCD TV ' , 1 , 6999 , ' Sony ' , ' Beijing ' ); INSERT INTO product VALUES( 12 , ' Lenovo 14.0 inch laptop ' , 3 , 2999 , ' Lenovo ' , ' Beijing ' ); INSERT INTO product VALUES( 13 , ' Lenovo dual SIM dual standby 3G mobile phone ' , 2 , 988 , ' Lenovo ' , ' Beijing ' ); INSERT INTO product VALUES( 15 , ' Hewlett-Packard (HP) black and white laser printer ' , 3 , 1169 , ' HP ' , ' Tianjin ' ); -- 1 The brands whose prices are between 1000 and 5000 are Lenovo's product names, product prices, and product types SELECT pro_name,price,protype_name FROM product JOIN product_type ON product.`protype_id` = product_type.`protype_id` WHERE price BETWEEN 1000 AND 5000; -- 2 Query the brand, origin, and quantity of products of this brand for all brands of the same product type as the product with id 5, SELECT pinpai,chandi,COUNT(pinpai) FROM product WHERE protype_id =(SELECT protype_id FROM product WHERE proid = 5) GROUP BY pinpai; -- 3 Delete records with id greater than 7 in the product type table DELETE FROM product_type WHERE protype_id>7; -- 4 Modify 'home furniture' to 'furniture supplies'; UPDATE product_type SET protype_name ='家具用品' WHERE protype_id = 5; -- 5 Inquire about the brand and price of all products under 'Household Appliances' SELECT pinpai,price FROM product JOIN product_type ON product.`protype_id` = product.`protype_id` WHERE protype_name = '家用电器';