Mysql数据库实例 —— 物流管理平台

本文最后更新于:2022年4月10日 晚上

源自网络,仅作参考!

介绍

联系

ER图

SQL语句

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
Navicat MySQL Data Transfer

Source Server : 本地连接
Source Server Type : MySQL
Source Server Version : 50527
Source Host : localhost:3306
Source Schema : 物资管理数据库系统

Target Server Type : MySQL
Target Server Version : 50527
File Encoding : 65001

Date: 22/04/2020 10:51:45
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for 仓库
-- ----------------------------
DROP TABLE IF EXISTS `仓库`;
CREATE TABLE `仓库` (
`仓库编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`仓库管理员` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`联系电话` int(11) NULL DEFAULT NULL,
`仓库地址` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`仓库编号`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 仓库存储系统
-- ----------------------------
DROP TABLE IF EXISTS `仓库存储系统`;
CREATE TABLE `仓库存储系统` (
`仓库编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品价格` float(255, 2) NULL DEFAULT NULL,
`库存数量` int(255) NULL DEFAULT NULL,
PRIMARY KEY (`仓库编号`, `产品编号`) USING BTREE,
INDEX `产品`(`产品编号`) USING BTREE,
CONSTRAINT `产品` FOREIGN KEY (`产品编号`) REFERENCES `医疗物资` (`产品编号`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `仓库` FOREIGN KEY (`仓库编号`) REFERENCES `仓库` (`仓库编号`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 出售联系
-- ----------------------------
DROP TABLE IF EXISTS `出售联系`;
CREATE TABLE `出售联系` (
`厂家登录名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品价格` float(255, 2) NULL DEFAULT NULL,
`库存数量` int(255) NULL DEFAULT NULL,
PRIMARY KEY (`厂家登录名`, `产品编号`) USING BTREE,
INDEX `医疗物资`(`产品编号`) USING BTREE,
CONSTRAINT `医疗物资` FOREIGN KEY (`产品编号`) REFERENCES `医疗物资` (`产品编号`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `厂家` FOREIGN KEY (`厂家登录名`) REFERENCES `厂家` (`登录名`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 医疗物资
-- ----------------------------
DROP TABLE IF EXISTS `医疗物资`;
CREATE TABLE `医疗物资` (
`产品编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`产品类别` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`厂家名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`产品编号`) USING BTREE,
INDEX `所属公司`(`厂家名称`) USING BTREE,
CONSTRAINT `所属公司` FOREIGN KEY (`厂家名称`) REFERENCES `厂家` (`登录名`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 医院
-- ----------------------------
DROP TABLE IF EXISTS `医院`;
CREATE TABLE `医院` (
`用户名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`采购员` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`联系方式` int(11) NULL DEFAULT NULL,
`CID` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`口罩需求量` int(255) NULL DEFAULT NULL,
`防护服需求量` int(255) NULL DEFAULT NULL,
`呼吸机需求量` int(255) NULL DEFAULT NULL,
PRIMARY KEY (`用户名`) USING BTREE,
INDEX `CID`(`CID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 厂家
-- ----------------------------
DROP TABLE IF EXISTS `厂家`;
CREATE TABLE `厂家` (
`登录名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`联系电话` int(11) NULL DEFAULT NULL,
`有效营业执照` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`银行卡号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`仓库编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`登录名`) USING BTREE,
INDEX `仓库号`(`仓库编号`) USING BTREE,
CONSTRAINT `仓库号` FOREIGN KEY (`仓库编号`) REFERENCES `仓库` (`仓库编号`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 取货货单
-- ----------------------------
DROP TABLE IF EXISTS `取货货单`;
CREATE TABLE `取货货单` (
`货单编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`仓库编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`取货数量` int(255) NULL DEFAULT NULL,
`取货时间` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`采购员编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`送货员联系方式` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`货单编号`) USING BTREE,
INDEX `产品编号`(`产品编号`) USING BTREE,
INDEX `仓库编号`(`仓库编号`) USING BTREE,
INDEX `采购员`(`采购员编号`) USING BTREE,
CONSTRAINT `采购员` FOREIGN KEY (`采购员编号`) REFERENCES `医院` (`CID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `产品编号` FOREIGN KEY (`产品编号`) REFERENCES `医疗物资` (`产品编号`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `仓库编号` FOREIGN KEY (`仓库编号`) REFERENCES `仓库` (`仓库编号`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `取货员` FOREIGN KEY (`采购员编号`) REFERENCES `送货员` (`S_ID`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 物流公司
-- ----------------------------
DROP TABLE IF EXISTS `物流公司`;
CREATE TABLE `物流公司` (
`公司名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
`送货员` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`S_ID` int(30) NULL DEFAULT NULL,
`联系电话` int(30) NULL DEFAULT NULL,
`收货人` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`产品名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`寄货人` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`配送状态` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`公司名称`) USING BTREE,
INDEX `S_ID`(`S_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 签约
-- ----------------------------
DROP TABLE IF EXISTS `签约`;
CREATE TABLE `签约` (
`厂家名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`签约时间` int(255) NULL DEFAULT NULL,
`公司名称` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`厂家名`, `公司名称`) USING BTREE,
INDEX `物公司`(`公司名称`) USING BTREE,
CONSTRAINT `物公司` FOREIGN KEY (`公司名称`) REFERENCES `物流公司` (`公司名称`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `公司名` FOREIGN KEY (`厂家名`) REFERENCES `厂家` (`登录名`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 送货员
-- ----------------------------
DROP TABLE IF EXISTS `送货员`;
CREATE TABLE `送货员` (
`S_ID` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`姓名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`联系方式` int(11) NULL DEFAULT NULL,
`所属公司` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`S_ID`) USING BTREE,
INDEX `所属`(`所属公司`) USING BTREE,
CONSTRAINT `所属` FOREIGN KEY (`所属公司`) REFERENCES `物流公司` (`公司名称`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 配送联系
-- ----------------------------
DROP TABLE IF EXISTS `配送联系`;
CREATE TABLE `配送联系` (
`送货单号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`送货员编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`联系方式` int(255) NULL DEFAULT NULL,
`货物编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`预计送达时间` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`出货仓库编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`收货人` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`送货单号`) USING BTREE,
INDEX `送货员`(`送货员编号`) USING BTREE,
INDEX `物资编号`(`货物编号`) USING BTREE,
INDEX `出货仓库`(`出货仓库编号`) USING BTREE,
INDEX `医院用户名`(`收货人`) USING BTREE,
CONSTRAINT `送货员` FOREIGN KEY (`送货员编号`) REFERENCES `送货员` (`S_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `出货仓库` FOREIGN KEY (`出货仓库编号`) REFERENCES `仓库` (`仓库编号`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `医院用户名` FOREIGN KEY (`收货人`) REFERENCES `医院` (`用户名`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Table structure for 采购联系
-- ----------------------------
DROP TABLE IF EXISTS `采购联系`;
CREATE TABLE `采购联系` (
`订单号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`产品编号` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`采购数量` int(255) NULL DEFAULT NULL,
`采购时间` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`用户名` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`订单号`) USING BTREE,
INDEX `产品编号1`(`产品编号`) USING BTREE,
INDEX `医院名`(`用户名`) USING BTREE,
CONSTRAINT `医院名` FOREIGN KEY (`用户名`) REFERENCES `医院` (`用户名`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `产品编号1` FOREIGN KEY (`产品编号`) REFERENCES `医疗物资` (`产品编号`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

SET FOREIGN_KEY_CHECKS = 1;