程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2023-06(4)

天猫整站Springboot 从零开始搭建(四(1))

发布于2021-06-08 09:29     阅读(914)     评论(0)     点赞(24)     收藏(0)


2.2.2 用户表

  1. mysql> create table user(
  2. -> id int(11) not null auto_increment,
  3. -> name varchar(255) default null,
  4. -> password varchar(255) default null,
  5. -> salt varchar(255) default null,
  6. -> primary key (id)
  7. -> )engine=InnoDB default charset=utf8;

2.2.3 分类表

  1. mysql> create table category(
  2. -> id int(11) not null auto_increment,
  3. -> name varchar(255) default null,
  4. -> primary key (id)
  5. -> )engine=InnoDB default charset=utf8;

2.2.4 属性表

从这个表开始, 就有外键约束了。
本表的外键cid,指向分类表的id字段

  1. mysql> create table property(
  2. -> id int(11) not null auto_increment,
  3. -> cid int(11) default null,
  4. -> name varchar(255) default null,
  5. -> primary key (id),
  6. -> constraint fk_property_category foreign key (cid) references category (id)
  7. -> ) engine=InnoDB default charset=utf8;

2.2.5 产品表

产品表字段稍多,讲解一下
name: 产品名称
subTitle: 小标题
originalPrice: 原始价格
promotePrice: 优惠价格
stock: 库存
createDate: 创建日期

本表的外键cid,指向分类表的id字段

  1. CREATE TABLE product (
  2. id int(11) NOT NULL AUTO_INCREMENT,
  3. name varchar(255) DEFAULT NULL,
  4. subTitle varchar(255) DEFAULT NULL,
  5. originalPrice float DEFAULT NULL,
  6. promotePrice float DEFAULT NULL,
  7. stock int(11) DEFAULT NULL,
  8. cid int(11) DEFAULT NULL,
  9. createDate datetime DEFAULT NULL,
  10. PRIMARY KEY (id),
  11. CONSTRAINT fk_product_category FOREIGN KEY (cid) REFERENCES category (id)
  12. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

2.2.6 属性值表

在产品页的商品详情标签下,显示本产品的所有属性值

本表有两个外键
外键ptid,指向属性表的id字段
外键pid,指向产品表的id字段

  1. mysql> create table propertyvalue(
  2. -> id int(11) not null auto_increment,
  3. -> pid int(11) default null,
  4. -> ptid int(11) default null,
  5. -> value varchar(255) default null,
  6. -> primary key(id),
  7. -> constraint fk_propertyvalue_property foreign key (ptid) references property(id),
  8. -> constraint fk_propertyvalue_product foreign key (pid) references product(id)
  9. -> )engine=InnoDB default charset=utf8;

2.2.7 产品图片表

在产品页显示5个单个图片

type表示类型,产品图片分单个图片和详情图片两种
本表的外键pid,指向产品表的id字段

  1. CREATE TABLE productimage (
  2. id int(11) NOT NULL AUTO_INCREMENT,
  3. pid int(11) DEFAULT NULL,
  4. type varchar(255) DEFAULT NULL,
  5. PRIMARY KEY (id),
  6. CONSTRAINT fk_productimage_product FOREIGN KEY (pid) REFERENCES product (id)
  7. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.2.8 评价表

外键pid,指向产品表的id字段
外键uid,指向用户表的id字段

  1. CREATE TABLE review (
  2. id int(11) NOT NULL AUTO_INCREMENT,
  3. content varchar(4000) DEFAULT NULL,
  4. uid int(11) DEFAULT NULL,
  5. pid int(11) DEFAULT NULL,
  6. createDate datetime DEFAULT NULL,
  7. PRIMARY KEY (id),
  8. CONSTRAINT fk_review_product FOREIGN KEY (pid) REFERENCES product (id),
  9. CONSTRAINT fk_review_user FOREIGN KEY (uid) REFERENCES user (id)
  10. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.2.9 订单表

订单表的字段也比较多,讲解一下:
orderCode: 订单号
address:收货地址
post: 邮编
receiver: 收货人信息
mobile: 手机号码
userMessage: 用户备注信息
createDate: 订单创建日期
payDate: 支付日期
deliveryDate: 发货日期
confirmDate:确认收货日期
status: 订单状态
外键uid,指向用户表id字段

  1. CREATE TABLE order_ (
  2. id int(11) NOT NULL AUTO_INCREMENT,
  3. orderCode varchar(255) DEFAULT NULL,
  4. address varchar(255) DEFAULT NULL,
  5. post varchar(255) DEFAULT NULL,
  6. receiver varchar(255) DEFAULT NULL,
  7. mobile varchar(255) DEFAULT NULL,
  8. userMessage varchar(255) DEFAULT NULL,
  9. createDate datetime DEFAULT NULL,
  10. payDate datetime DEFAULT NULL,
  11. deliveryDate datetime DEFAULT NULL,
  12. confirmDate datetime DEFAULT NULL,
  13. uid int(11) DEFAULT NULL,
  14. status varchar(255) DEFAULT NULL,
  15. PRIMARY KEY (id),
  16. CONSTRAINT fk_order_user FOREIGN KEY (uid) REFERENCES user (id)
  17. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.2.10 订单项表

这个表是外键最多的一个表
外键pid,指向产品表id字段
外键oid,指向订单表id字段
外键uid,指向用户表id字段
number字段表示购买数量

  1. CREATE TABLE orderitem (
  2. id int(11) NOT NULL AUTO_INCREMENT,
  3. pid int(11) DEFAULT NULL,
  4. oid int(11) DEFAULT NULL,
  5. uid int(11) DEFAULT NULL,
  6. number int(11) DEFAULT NULL,
  7. PRIMARY KEY (id),
  8. CONSTRAINT fk_orderitem_user FOREIGN KEY (uid) REFERENCES user (id),
  9. CONSTRAINT fk_orderitem_product FOREIGN KEY (pid) REFERENCES product (id),
  10. CONSTRAINT fk_orderitem_order FOREIGN KEY (oid) REFERENCES order_ (id)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

 



所属网站分类: 技术文章 > 博客

作者:飞向远方

链接:http://www.javaheidong.com/blog/article/219250/43da292dd0824220aa6f/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

24 0
收藏该文
已收藏

评论内容:(最多支持255个字符)