数据库

create database productstore character set utf8 collate utf8_bin;

USE productstore;
-- 用户表
CREATE TABLE `user` (
  `id` INT(11) AUTO_INCREMENT,
  `userName` VARCHAR(20) ,
  `password` VARCHAR(20) ,
  `gender` VARCHAR(10) ,
  `email` VARCHAR(50) ,
  `telephone` VARCHAR(20) ,
  `introduce` VARCHAR(100),
  `activeCode` VARCHAR(50) ,
  `state` INT(11) ,
  `role` VARCHAR(20) default 'defaultUser',
  `registTime` TIMESTAMP ,
  PRIMARY KEY (`id`)
);

-- 商品表
CREATE TABLE `products` (
  `id` VARCHAR(100) ,
  `name` VARCHAR(40) ,
  `price` DOUBLE ,
  `category` VARCHAR(40) ,
  `pnum` INT(11) ,
  `imgurl` VARCHAR(100) ,
  `description` VARCHAR(255) ,
  PRIMARY KEY (`id`)
);

-- 订单表
CREATE TABLE `orders` (
  `id`              VARCHAR(100),
  `money`           DOUBLE,
  `receiverAddress` VARCHAR(255),
  `receiverName`    VARCHAR(20),
  `receiverPhone`   VARCHAR(20),
  `paystate`        INT(11),
  `ordertime`       TIMESTAMP,
  `user_id`         INT(11),
  PRIMARY KEY (`id`),
  FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
);
-- 订单项表
CREATE TABLE `orderitem` (
  `order_id` VARCHAR(100) ,
  `product_id` VARCHAR(100),
  `buynum` INT(11) ,
  PRIMARY KEY (`order_id`,`product_id`),
  FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`),
  FOREIGN KEY (`product_id`) REFERENCES `products` (`id`)
)

扎瓦
36 声望33 粉丝

笑吾庐,门掩草,径封苔。