/*
Navicat MySQL Data Transfer
Source Server : 练习
Source Server Version : 50556
Source Host : localhost:3306
Source Database : 自主订餐
Target Server Type : MYSQL
Target Server Version : 50556
File Encoding : 65001
Date: 2017-10-22 15:17:32
*/
SET FOREIGN_KEY_CHECKS=0;
– Table structure for account
DROP TABLE IF EXISTS account
;
CREATE TABLE account
(
id
int(11) NOT NULL AUTO_INCREMENT,
account
varchar(255) DEFAULT NULL,
password
varchar(255) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
– Records of account
INSERT INTO account
VALUES (‘1’, ‘张三’, ‘123456’);
INSERT INTO account
VALUES (‘2’, ‘李四’, ‘123456’);
INSERT INTO account
VALUES (‘3’, ‘王五’, ‘123456’);
– Table structure for customer
DROP TABLE IF EXISTS customer
;
CREATE TABLE customer
(
id
int(11) NOT NULL AUTO_INCREMENT,
name
varchar(255) DEFAULT NULL,
telephone
varchar(255) DEFAULT NULL,
order_number
varchar(255) DEFAULT NULL,
customer_id
int(11) DEFAULT NULL,
account_id
int(11) DEFAULT NULL,
PRIMARY KEY (id
),
KEY fk_sum_cus
(customer_id
),
KEY fk_account_cus
(account_id
),
CONSTRAINT fk_account_cus
FOREIGN KEY (account_id
) REFERENCES account
(id
),
CONSTRAINT fk_sum_cus
FOREIGN KEY (customer_id
) REFERENCES summary_statement
(id
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
– Records of customer
INSERT INTO customer
VALUES (‘1’, ‘张三’, ‘24352’, ‘D1’, ‘1’, ‘1’);
INSERT INTO customer
VALUES (‘2’, ‘李四’, ‘32424’, ‘D2’, ‘2’, ‘2’);
INSERT INTO customer
VALUES (‘3’, ‘王五’, ‘23456’, ‘D3’, ‘3’, ‘3’);
– Table structure for menu
DROP TABLE IF EXISTS menu
;
CREATE TABLE menu
(
id
int(11) NOT NULL AUTO_INCREMENT,
name
varchar(255) DEFAULT NULL,
price
decimal(10,0) DEFAULT NULL,
menu_id
int(11) DEFAULT NULL,
PRIMARY KEY (id
),
KEY fk_menu_order
(menu_id
),
CONSTRAINT fk_menu_order
FOREIGN KEY (menu_id
) REFERENCES order_details
(id
)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
– Records of menu
INSERT INTO menu
VALUES (‘1’, ‘鱼香肉丝’, ‘24’, ‘1’);
INSERT INTO menu
VALUES (‘2’, ‘宫保鸡丁’, ‘20’, ‘1’);
INSERT INTO menu
VALUES (‘3’, ‘东坡肉’, ‘30’, ‘2’);
INSERT INTO menu
VALUES (‘4’, ‘肉末茄子’, ‘13’, ‘3’);
INSERT INTO menu
VALUES (‘5’, ‘青菜’, ‘8’, ‘2’);
INSERT INTO menu
VALUES (‘6’, ‘豆腐’, ‘7’, ‘2’);
– Table structure for order_details
DROP TABLE IF EXISTS order_details
;
CREATE TABLE order_details
(
id
int(11) NOT NULL AUTO_INCREMENT,
order_time
datetime DEFAULT NULL,
code
varchar(255) DEFAULT NULL,
order_id
int(11) DEFAULT NULL,
PRIMARY KEY (id
),
KEY fk_order_customer
(order_id
),
CONSTRAINT fk_order_customer
FOREIGN KEY (order_id
) REFERENCES customer
(id
)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
– Records of order_details
INSERT INTO order_details
VALUES (‘1’, ‘2017-10-20 15:41:12’, ‘D1’, ‘1’);
INSERT INTO order_details
VALUES (‘2’, ‘2017-10-20 15:42:05’, ‘D2’, ‘1’);
INSERT INTO order_details
VALUES (‘3’, ‘2017-10-20 15:42:10’, ‘D3’, ‘2’);
INSERT INTO order_details
VALUES (‘4’, ‘2017-10-20 15:42:17’, ‘D4’, ‘3’);
– Table structure for summary_statement
DROP TABLE IF EXISTS summary_statement
;
CREATE TABLE summary_statement
(
id
int(11) NOT NULL AUTO_INCREMENT,
restaurant_name
varchar(255) DEFAULT NULL,
restaurant_address
varchar(255) DEFAULT NULL,
table_number
int(11) DEFAULT NULL,
people_number
int(11) DEFAULT NULL,
order_time
datetime DEFAULT NULL,
pay_time
datetime DEFAULT NULL,
restaurant_telephone
varchar(255) DEFAULT NULL,
customer_name
varchar(255) DEFAULT NULL,
price
decimal(10,0) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
– Records of summary_statement
INSERT INTO summary_statement
VALUES (‘1’, ‘兰州拉面’, ‘南通’, ‘12345’, ‘4’, ‘2017-10-20 15:31:42’, ‘2017-10-20 15:31:44’, ‘2454’, ‘张三’, null);
INSERT INTO summary_statement
VALUES (‘2’, ‘肯德基’, ‘南通’, ‘2355’, ‘5’, ‘2017-10-20 15:32:40’, ‘2017-10-20 15:32:42’, ‘36323’, ‘李四’, null);
INSERT INTO summary_statement
VALUES (‘3’, ‘沙县小吃’, ‘南通’, ‘254553’, ‘6’, ‘2017-10-20 15:33:09’, ‘2017-10-20 15:33:12’, ‘3546635’, ‘王五’, null);