MySQL数据库课设
Posted 无乎648
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL数据库课设相关的知识,希望对你有一定的参考价值。
数据库应用课程设计-线上美食订购数据库系统
一、项目简介
商家可以由食材供货源提供相应的食材,其中食材供货源有联系电话、负责人姓名、地址、供应商名称和供应商编号属性五个属性,其中供应商编号是唯一标识码,不同的食材供货源可以为不同的商家提供食材,并产生了提供量属性,商家有好评度、姓名、收入、账号和评价等级五个属性,其中账号是商家的唯一标识码。商家开设了线下餐厅和雇佣了外卖员,线下餐厅有餐厅号、餐厅好评度、外卖员编号和就餐人数四个属性,其中餐厅号是唯一标识码,外卖员编号是外键。外卖员有外卖员编号、联系方式、性别、外卖员好评度、外卖员编号和外卖员姓名,其中外卖员编号是唯一标识码。多个外卖员又隶属一个线下餐厅。
一个线下餐厅包括多个美食实体,美食有美食编号、价格、美食名称、销售量、餐厅号和美食好评度六个属性,其中美食编号是唯一标识码,餐厅号是外键。同一种美食通过销售可以产生多个销售额,销售额有销售编号、收入金额和美食编号三个属性,其中销售编号是唯一标识码,美食编号是外键。
不同的用户可以就餐多种不同的美食,产生了就餐时间属性,用户有用户账号、用户等级、姓名、地址和联系信息五个属性。一个用户包括一个钱包,钱包有用户账号、银行卡号、余额、优惠券和信任积分五个属性,其中用户账号是唯一标识码。多个不同的用户通过订外卖产生了多个不同的订单实体,并有订餐时间的属性,订单有订单号、用户地址、美食编号、数量、餐厅号、外卖员编号和总价七个属性,其中订单号是唯一标识码,用户账号、外卖员编号是外键。一个用户可以评论产生多个评论区实体,评论区有评论编号、订单号、美食编号、用户账号、餐厅好评度、餐厅号、评价等级、美食好评度和外卖员编号九个属性,其中订单号是唯一标识码,用户账号是外键。
多个不同的外卖员通过送外卖产生多个不同的订单实体,并产生了订单时间属性。
二、数据库概念设计
(1)商家实体具体属性如下图:
(2)线下餐厅实体具体属性如下图:
(3)外卖员实体具体属性如下图:
(4)美食实体具体属性如下图:
(5)用户实体具体属性如下图:
(6)订单实体具体属性如下图:
(7)评论区实体具体属性如下图:
(8)销售额实体的具体属性如下图:
(9)钱包实体的具体属性如下图:
(10)食材供货源的具体属性如下图:
系统基本功能的E-R图如下:
三、mysql代码(更加详细解释的见我资源分享)
-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: jingmaowaimai
-- ------------------------------------------------------
-- Server version 8.0.23
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `business`
--
DROP TABLE IF EXISTS `business`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `business` (
`ID` int NOT NULL COMMENT '编号',
`good` int DEFAULT NULL COMMENT '好评度',
`grade` int DEFAULT NULL COMMENT '评价等级',
`money` varchar(12) DEFAULT NULL COMMENT '收入',
`business_name` varchar(12) DEFAULT NULL COMMENT '姓名',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商家';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `business`
--
LOCK TABLES `business` WRITE;
/*!40000 ALTER TABLE `business` DISABLE KEYS */;
INSERT INTO `business` VALUES (1,8,3,'56768','山东煎饼'),(2,9,4,'45220','张姐烤肉拌饭'),(3,6,2,'1230','兰州拉面'),(4,8,5,'4500','火锅鸡');
/*!40000 ALTER TABLE `business` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Temporary view structure for view `caidan`
--
DROP TABLE IF EXISTS `caidan`;
/*!50001 DROP VIEW IF EXISTS `caidan`*/;
SET @saved_cs_client = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `caidan` AS SELECT
1 AS `user_name`,
1 AS `address`,
1 AS `food_name`,
1 AS `dine_time`*/;
SET character_set_client = @saved_cs_client;
--
-- Table structure for table `comment_area`
--
DROP TABLE IF EXISTS `comment_area`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `comment_area` (
`comment_ID` varchar(8) NOT NULL COMMENT '评论编号',
`restaurant_ID` varchar(8) NOT NULL COMMENT '餐厅号',
`order_ID` varchar(8) NOT NULL COMMENT '订单号',
`food_ID` varchar(8) NOT NULL COMMENT '美食编号',
`deliveryman_ID` varchar(8) NOT NULL COMMENT '外卖员编号',
`food_good` int DEFAULT NULL COMMENT '美食好评度',
`comment_grade` varchar(8) DEFAULT NULL COMMENT '评价等级',
`restaurant_good` int DEFAULT NULL COMMENT '餐厅好评度',
`user_ID` varchar(8) NOT NULL COMMENT '用户账号',
PRIMARY KEY (`comment_ID`),
KEY `food_ID_idx` (`food_ID`),
KEY `restaurant_ID_idx` (`restaurant_ID`),
KEY `order_ID_idx` (`order_ID`),
KEY `deliveryman_ID _idx` (`deliveryman_ID`),
KEY `fk_comment_area_user1_idx` (`user_ID`),
CONSTRAINT `fk_comment_area_user1` FOREIGN KEY (`user_ID`) REFERENCES `user` (`user_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='评论区';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `comment_area`
--
LOCK TABLES `comment_area` WRITE;
/*!40000 ALTER TABLE `comment_area` DISABLE KEYS */;
INSERT INTO `comment_area` VALUES ('1','2','2','001','001',7,'7',7,'002'),('2','3','3','002','002',8,'9',8,'001');
/*!40000 ALTER TABLE `comment_area` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `deliver`
--
DROP TABLE IF EXISTS `deliver`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `deliver` (
`deliveryman_ID` varchar(8) NOT NULL COMMENT '外卖员编号',
`order_ID` int NOT NULL COMMENT '订单编号',
`time` varchar(45) NOT NULL COMMENT '订单时间',
PRIMARY KEY (`deliveryman_ID`,`order_ID`,`time`),
KEY `fk_deliveryman_has_order_order1_idx` (`order_ID`),
KEY `fk_deliveryman_has_order_deliveryman1_idx` (`deliveryman_ID`),
CONSTRAINT `fk_deliveryman_has_order_deliveryman1` FOREIGN KEY (`deliveryman_ID`) REFERENCES `deliveryman` (`deliveryman_ID`),
CONSTRAINT `fk_deliveryman_has_order_order1` FOREIGN KEY (`order_ID`) REFERENCES `order` (`order_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `deliver`
--
LOCK TABLES `deliver` WRITE;
/*!40000 ALTER TABLE `deliver` DISABLE KEYS */;
INSERT INTO `deliver` VALUES ('001',2,'12:10'),('002',3,'13:40');
/*!40000 ALTER TABLE `deliver` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `deliveryman`
--
DROP TABLE IF EXISTS `deliveryman`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `deliveryman` (
`deliveryman_ID` varchar(8) NOT NULL COMMENT '外卖员编号',
`deliveryman_name` varchar(12) DEFAULT NULL COMMENT '外卖员姓名',
`deliveryman_good` int DEFAULT NULL COMMENT '外卖员好评度',
`deliveryman_sex` varchar(2) DEFAULT NULL COMMENT '性别',
`deliveryman_num` varchar(12) DEFAULT NULL COMMENT '联系方式',
`jingmaowaimai_ID` int NOT NULL,
PRIMARY KEY (`deliveryman_ID`),
KEY `fk_deliveryman_jingmaowaimai1_idx` (`jingmaowaimai_ID`),
CONSTRAINT `fk_deliveryman_jingmaowaimai1` FOREIGN KEY (`jingmaowaimai_ID`) REFERENCES `business` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='外卖员';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `deliveryman`
--
LOCK TABLES `deliveryman` WRITE;
/*!40000 ALTER TABLE `deliveryman` DISABLE KEYS */;
INSERT INTO `deliveryman` VALUES ('001','小王',9,'男','123456',1),('002','小刘',8,'女','324156',2),('003','小张',8,'男','123432',3);
/*!40000 ALTER TABLE `deliveryman` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `dine`
--
DROP TABLE IF EXISTS `dine`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `dine` (
`food_ID` varchar(45) NOT NULL COMMENT '美食编号',
`user_ID` varchar(8) NOT NULL COMMENT '用户账号',
`dine_time` varchar(45) NOT NULL COMMENT '就餐时间',
PRIMARY KEY (`food_ID`,`user_ID`,`dine_time`),
KEY `fk_food_has_user_user1_idx` (`user_ID`),
KEY `fk_food_has_user_food1_idx` (`food_ID`),
CONSTRAINT `fk_food_has_user_food1` FOREIGN KEY (`food_ID`) REFERENCES `food` (`food_ID`),
CONSTRAINT `fk_food_has_user_user1` FOREIGN KEY (`user_ID`) REFERENCES `user` (`user_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `dine`
--
LOCK TABLES `dine` WRITE;
/*!40000 ALTER TABLE `dine` DISABLE KEYS */;
INSERT INTO `dine` VALUES ('005','001','16:00'),('006','001','12:30'),('002','002','12:00'),('004','002','17:00'),('006','002','14:00'),('001','003','18:00'),('003','003','19:00');
/*!40000 ALTER TABLE `dine` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `food`
--
DROP TABLE IF EXISTS `food`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `food` (
`food_ID` varchar(45) NOT NULL COMMENT '美食编号',
`food_name` varchar(12) NOT NULL COMMENT '美食名称',
`food_sale` varchar(12) DEFAULT NULL COMMENT '美食销售量',
`food_price` int NOT NULL COMMENT '价格',
`food_good` int DEFAULT NULL COMMENT '好评度',
`restaurant_ID` varchar(8) NOT NULL COMMENT '餐厅号',
PRIMARY KEY (`food_ID`),
KEY `fk_food_restaurant1_idx` (`restaurant_ID`),
CONSTRAINT `fk_food_restaurant1` FOREIGN KEY (`restaurant_ID`) REFERENCES `restaurant` (`restaurant_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='美食';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `food`
--
LOCK TABLES `food` WRITE;
/*!40000 ALTER TABLE `food` DISABLE KEYS */;
INSERT INTO `food` VALUES ('001','煎饼','55000',5,9,'1'),('002','包子','4500',3,6,'3'),('003','汉堡','234',5,6,'3'),('004','蒸饺','4500',6,6,'2'),('005','火锅鸡','8900',50,8,'3'),('006','麻辣香锅','79800',40,7,'1');
/*!40000 ALTER TABLE `food` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Temporary view structure for view `jinhuo`
--
DROP TABLE IF EXISTS `jinhuo`;
/*!50001 DROP VIEW IF EXISTS `jinhuo`*/;
SET @saved_cs_client = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `jinhuo` AS SELECT
1 AS `supplier_name`,
1 AS `address`,
1 AS `people_name`,
1 AS `business_name`,
1 AS `sum`*/;
SET character_set_client = @saved_cs_client;
--
-- Table structure for table `order`
--
DROP TABLE 以上是关于MySQL数据库课设的主要内容,如果未能解决你的问题,请参考以下文章
Python flask博客系统多用户版(课设毕设学习源码下载)