用mysql写一个菜品数据库
时间: 2024-05-18 16:17:02 浏览: 46
好的,以下是一个简单的菜品数据库设计:
1. 食材表
CREATE TABLE `ingredients` (
`ingredient_id` INT NOT NULL AUTO_INCREMENT,
`ingredient_name` VARCHAR(50) NOT NULL,
`ingredient_description` VARCHAR(200),
PRIMARY KEY (`ingredient_id`)
) ENGINE=InnoDB;
2. 菜品表
CREATE TABLE `recipes` (
`recipe_id` INT NOT NULL AUTO_INCREMENT,
`recipe_name` VARCHAR(50) NOT NULL,
`recipe_description` VARCHAR(200),
`recipe_image` VARCHAR(200),
PRIMARY KEY (`recipe_id`)
) ENGINE=InnoDB;
3. 菜品食材关系表
CREATE TABLE `recipe_ingredients` (
`recipe_id` INT NOT NULL,
`ingredient_id` INT NOT NULL,
`ingredient_amount` VARCHAR(50),
FOREIGN KEY (`recipe_id`) REFERENCES `recipes` (`recipe_id`),
FOREIGN KEY (`ingredient_id`) REFERENCES `ingredients` (`ingredient_id`)
) ENGINE=InnoDB;
4. 步骤表
CREATE TABLE `steps` (
`step_id` INT NOT NULL AUTO_INCREMENT,
`step_description` VARCHAR(200),
`step_image` VARCHAR(200),
PRIMARY KEY (`step_id`)
) ENGINE=InnoDB;
5. 菜品步骤关系表
CREATE TABLE `recipe_steps` (
`recipe_id` INT NOT NULL,
`step_id` INT NOT NULL,
`step_order` INT NOT NULL,
FOREIGN KEY (`recipe_id`) REFERENCES `recipes` (`recipe_id`),
FOREIGN KEY (`step_id`) REFERENCES `steps` (`step_id`)
) ENGINE=InnoDB;
这个数据库设计可以让用户查看菜品,并了解菜品所需要的食材和步骤。您可以根据需要进一步完善设计,例如添加用户评价或者菜品分类等。
阅读全文