goods表
mysql> create table if not exists goods(
-> goods_id int primary key auto_increment comment '商品编号',
-> goods_name varchar(32) not null comment '商品名称',
-> unitprice int not null default 0 comment '单价,单位分',
-> category varchar(12) comment '商品分类',
-> provider varchar(64) not null comment '供应商名称');
customer表
mysql> create table customer(
-> customer_id int primary key auto_increment comment '客户号',
-> name varchar(32) not null comment '姓名',
-> address varchar(64) comment '住址',
-> email varchar(32) unique key comment '邮箱',
-> sex enum('男','女') not null comment '性别',
-> card_id char(18) unique key comment '身份证');
purchase表
mysql> create table purchase(
-> order_id int primary key auto_increment comment '购买订单号',
-> customer_id int comment '客户号',
-> goods_id int comment '商品号',
-> nums int not null comment '购买数量',
-> foreign key (customer_id) references customer(customer_id),
-> foreign key (goods_id) references goods(goods_id));