个人博客网:https://wushaopei.github.io/    (你想要这里多有)

一、商品模块

商品实体信息所存储的表包括:

品牌信息表:

create table `brand_info`(
brand_id SMALLINT UNSIGNED auto_increment not null comment '品牌',
brand_name varchar(50) not null comment '品牌名称',
telephone varchar(50) not null comment '联系电话',
brand_web varchar(100) comment '品牌网站',
brand_logo varchar(100) comment '品牌logo URL',
brand_desc VARCHAR(150) comment '品牌描述',
brand_status tinyint not null DEFAULT 0 comment '品牌状态,0禁用,1启用',
brand_order TINYINT not null default 0 comment '排序',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_brandid (brand_id)
) ENGINE=INNODB comment '品牌信息表'
;

分类信息表:

create table `product_category`(
category_id SMALLINT UNSIGNED auto_increment not null comment '分类ID',
category_name varchar(10) not null comment '分类名称',
category_code varchar(10) not null comment '分类编码',
parent_id SMALLINT UNSIGNED not NULL DEFAULT 0 comment '父分类ID',
category_level TINYINT not null DEFAULT 1 comment '分类层级',
category_status TINYINT not null DEFAULT 1 comment '分类状态',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_categoryid (category_id)
) ENGINE=INNODB comment '商品分类表'
;

商品信息表:

create table `product_info`(
product_id int UNSIGNED auto_increment not null comment '商品ID',
product_code varchar(16) not null comment '商品编码',
product_name varchar(20) not null comment '商品名称',
bar_code varchar(50) not null comment '国条码',
barnd_id int UNSIGNED not NULL comment '品牌表的ID',
one_category_id SMALLINT UNSIGNED not null comment '一级分类ID',
two_category_id SMALLINT UNSIGNED not null comment '二级分类ID',
three_category_id SMALLINT UNSIGNED not null comment '三级分类ID',
supplier_id int UNSIGNED not null comment '商品的供应商id',
price DECIMAL(8,2) not null comment '商品销售价格',
average_cost DECIMAL(18,2) NOT null comment '商品加权平均成本',
publish_status TINYINT not null DEFAULT 0 comment '上下架状态:0下架,1上架',
audit_status TINYINT not null default 0 comment '审核状态:0未审核,1已审核',
weight float comment '商品重量',length float comment '商品长度',
heigh float comment '商品高度',width float comment '商品宽度',
color_type enum('红','黄','蓝','黑'),production_date datetime NOT NULL COMMENT '生产日期',
shelf_life int not null COMMENT '商品有效期',descript text not null COMMENT '商品描述',
indate TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP comment '商品录入时间',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_productid (product_id)
) ENGINE=INNODB comment '商品信息表'
;

商品图片表:

create table `product_pic_info`(
product_pic_id int UNSIGNED auto_increment not null comment '商品图片ID',
product_id int UNSIGNED not null comment '商品ID',
pic_desc varchar(50) comment '图片描述',
pic_url varchar(200) not null comment '图片URL',
is_master TINYINT not NULL DEFAULT 0 comment '是否主图:0.非主图1.主图',
pic_order TINYINT not null DEFAULT 0 comment '图片排序',
pic_status TINYINT not null DEFAULT 1 comment '图片是否有效:0无效 1有效',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_picid (product_pic_id)
) ENGINE=INNODB comment '商品信息表'
;

商品评论表:

create table `product_comment`(
comment_id int UNSIGNED auto_increment not null comment '评论ID',
product_id int UNSIGNED not null comment '商品ID',
order_id bigint UNSIGNED not null comment '订单ID',
customer_id int UNSIGNED not null comment '用户ID',
title varchar(50) not null comment '评论标题',
content varchar(300) not null comment '评论内容',
audit_status TINYINT not NULL comment '审核状态:0未审核1已审核',
audit_time TIMESTAMP not null comment '评论时间',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_commentid (comment_id)
) ENGINE=INNODB comment '商品评论表'
;

二、订单模块

订单实体包含的表有:

订单主表:

create table `order_master`(
order_id int UNSIGNED auto_increment not null comment '订单ID',
order_sn bigint UNSIGNED not null comment '订单编号 yyyymmddnnnnnnnn',
customer_id int UNSIGNED not null comment '下单人ID',
shipping_user VARCHAR(10) not null comment '收货人姓名',
province SMALLINT not null comment '省',city SMALLINT not null comment '市',
district SMALLINT not null comment '区',address VARCHAR(100) not null comment '地址',
payment_method TINYINT not null comment '支付方式:1现金,2余额,3网银,4支付宝,5微信',
order_money DECIMAL(8,2) not null comment '订单金额',
district_money DECIMAL(8,2) not null DEFAULT 0.00 comment '优惠金额',
shipping_money DECIMAL(8,2) not null DEFAULT 0.00 comment '运费金额',
payment_money DECIMAL(8,2) not null DEFAULT 0.00 comment '支付金额',
shipping_comp_name VARCHAR(10) COMMENT '快递公司名称',shipping_sn VARCHAR(50) comment '快递单号',
create_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP COMMENT '下单时间',
shipping_time datetime comment '发货时间',pay_time datetime comment '支付时间',
receive_time datetime comment '收货时间',order_status TINYINT not null DEFAULT 0 comment '订单状态',
order_point int UNSIGNED not null DEFAULT 0 comment '订单积分',
invoice_title VARCHAR(100) COMMENT '发票抬头',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_orderid (order_id)
) ENGINE=INNODB comment '订单主表'
;

订单详情表:

create table `order`.`order_detail`(
order_detail_id int UNSIGNED auto_increment not null comment '自增主键ID,订单详情表ID',
order_id int UNSIGNED not null comment '订单表ID',
product_id int UNSIGNED not null comment '订单商品ID',
product_name VARCHAR(50) not null comment '商品名称',
product_cnt INT not null default 1 comment '购买商品数量',
product_price DECIMAL(8,2) not null comment '购买商品单价',
average_cost DECIMAL(8,2) not null DEFAULT 0.00 comment '平均成本价格',
weight float comment '商品重量',
fee_money DECIMAL(8,2) not null DEFAULT 0.00 comment '优惠分摊金额',
w_id int UNSIGNED not null COMMENT '仓库ID',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_orderdetailid (order_detail_id)
) ENGINE=INNODB comment '订单详情表'
;

购物车表:

create table `order`.`order_cart`(
cart_id int UNSIGNED auto_increment not null comment '购物车ID',
customer_id int UNSIGNED not null comment '用户ID',
product_id int UNSIGNED not null comment '商品ID',
product_amount int not null comment '加入购物车商品数量',
price DECIMAL(8,2) not null comment '商品价格',
add_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP comment '加入购物车时间',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_cartid (cart_id)
) ENGINE=INNODB comment '购物车表'
;

仓库信息表:

create table `order`.`warehouse_info`(
w_id SMALLINT UNSIGNED auto_increment not null comment '仓库ID',
warehouse_sn char(5) not null comment '仓库编码',
warehouse_name VARCHAR(10) not null comment '仓库名称',
warehouse_phone VARCHAR(20) not null comment '仓库电话',
contact VARCHAR(10) not null comment '仓库联系人',
province SMALLINT not null comment '省',city SMALLINT not null comment '市',
district SMALLINT not null comment '区',address VARCHAR(100) not null comment '仓库地址',
warehouse_status TINYINT not null DEFAULT 1 comment '仓库状态:0禁用,1启用',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_wid (w_id)
) ENGINE=INNODB comment '仓库信息表'
;

商品库存表:

create table `order`.`warehouse_product`(
wp_id INT UNSIGNED auto_increment not null comment '商品库存ID',
product_id int UNSIGNED not null comment '商品ID',
w_id SMALLINT UNSIGNED not null comment '仓库ID',
currnet_cnt int UNSIGNED not null DEFAULT 0 comment '当前商品数量',
lock_cnt int UNSIGNED not null DEFAULT 0 comment '当前占用数据',
in_transit_cnt INT UNSIGNED not null DEFAULT 0 comment '在途数据',
average_cost DECIMAL(8,2) not null DEFAULT 0.00 comment '移动加权成本',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_wpid (wp_id)
) ENGINE=INNODB comment '商品库存表'
;

物流公司信息表:

create table `order`.`warehouse_product`(
wp_id INT UNSIGNED auto_increment not null comment '商品库存ID',
product_id int UNSIGNED not null comment '商品ID',
w_id SMALLINT UNSIGNED not null comment '仓库ID',
currnet_cnt int UNSIGNED not null DEFAULT 0 comment '当前商品数量',
lock_cnt int UNSIGNED not null DEFAULT 0 comment '当前占用数据',
in_transit_cnt INT UNSIGNED not null DEFAULT 0 comment '在途数据',
average_cost DECIMAL(8,2) not null DEFAULT 0.00 comment '移动加权成本',
modified_time TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '最后修改时间',
primary key pk_wpid (wp_id)
) ENGINE=INNODB comment '商品库存表'
;

三、DB规划

原因: 为以后数据库迁移提供方便

具体操作: 避免垮裤操作,把经常一起关联查询的表放到一个DB中

注意: 为了方便识别表所在的DB,在表名钱增加库名前缀

用户数据库

商品数据库:

订单数据库

高性能可扩展mysql 笔记(五)商品实体、订单实体、DB规划的更多相关文章

  1. 高性能可扩展mysql 笔记(一)数据库表、索引、SQL语句设计规范

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 项目说明:该笔记的背景为电商平台项目,电商项目由于其高并发.多线程.高耗能等特性,在众多的项目类型中涉及 ...

  2. 高性能可扩展mysql 笔记(六) SQL执行计划及分页查询优化、分区键统计

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 常见业务处理 一.使用数据库处理常见业务: 案例: 如何对评论进行分页展示 使用 EXPLAIN 获得s ...

  3. 高性能可扩展mysql 笔记(四)项目分区表演示

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 登录日志的分区 如何为Customer_login_log表分区? 从以下两个业务场景入手: 用户每次登 ...

  4. 高性能可扩展mysql 笔记(三)Hash分区、RANGE分区、LIST分区

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.MySQL分区表操作 1.定义:数据库表分区是数据库基本设计规范之一,分区表在物理上表现为多个文件, ...

  5. 高性能可扩展mysql 笔记(二)用户模型设计、用户实体表结构设计、设计范式

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.用户模型设计 电商羡慕中用户模型的设计涉及以下几个部分: ​ 以电商平台京东的登录.注册页面作为例: ...

  6. mysql颠覆实战笔记(五)--商品系统设计(二):定时更新商品总点击量

    继续回到沈老师的MYSQL颠覆实战,首先回顾下上一节课的内容,请大家会看下上节课写的存储过程. 打开prod_clicklog表, 我们只要把日期(不含时分秒)的部分存在数据库中, 如果同一日期有相同 ...

  7. 高性能可扩展MySQL数据库设计及架构优化 电商项目(慕课)第3章 MySQL执行计划(explain)分析

    ID:相同就从上而下,不同数字越大越优先

  8. mysql颠覆实战笔记(四)--商品系统设计(一):商品主表设计

    版权声明:笔记整理者亡命小卒热爱自由,崇尚分享.但是本笔记源自www.jtthink.com(程序员在囧途)沈逸老师的<web级mysql颠覆实战课程 >.如需转载请尊重老师劳动,保留沈逸 ...

  9. mysql颠覆实战笔记(六)--商品系统设计(三):商品属性设计之固定属性

    今天我们来讲一下商品属性 我们知道,不同类别的商品属性是不同的. 我们先建一个表prod_class_attr:

随机推荐

  1. 【Linux】1 创建目录:mkdir

    mkdir命令用于创建目录,如同一路径下创建单个或多个目录.递归创建目录,但同路径下不能创建同名目录,且目录名区分大小写. [命令] mkdir [用途] 创建目录(单个目录/多个目录) [语法] m ...

  2. 杂记---主要关于PHP导出excel表格学习

    今天上午处理了一下WIN7系统的电脑前置话筒和耳机口无法使用的问题,主要现象是耳机插入后没声音,麦插入话筒说话对方也听不到,后置端口一切正常.刚开始判断肯定是设置的问题,于是用另一台电脑百度搜索“wi ...

  3. Linux 内核工作队列之work_struct 学习总结

    前言 编写Linux驱动的时候对于work_struct的使用还是很普遍的,很早之前就在阅读驱动源码的时候就看到了它的踪影,根据其命名大概知道了它的具体作用,但是仍然不知所以,同时,伴随出现的还有de ...

  4. Django使用channel实现websocket

    channel 什么是channel? channel是第三方工具包,对于不支持websocket协议的框架可以借助此包实现websocket 安装 终端安装: pip3 install channe ...

  5. iOS事件的响应和传递机制

    跟二狗子哥哥交流的时候,他总说我,说的过程太业余.故 好好学习整理一下.努力不那么业余. 一.事件的产生.传递.响应: 1.事件从父控件依次传递到子控件,寻找最合适的子控件View. 2.寻找最合适的 ...

  6. java ->斗地主洗牌

    import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util ...

  7. 【转载】皇 家 国 际 开 户图像的插值算法18O88O49999

    插值的定义: 设函数y=f(x)在区间[a,b]上有定义,且已知在点a≤x0<x1<…<xn≤b上的值为y0,y1,…,yn,若存在简单函数P(x)使得 P(xi)=yi (i=0, ...

  8. JavaScript和TypeScript的区别和联系

    转载自:http://web.jobbole.com/93618/?utm_source=group.jobbole.com&utm_medium=relatedArticles JavaSc ...

  9. 初涉WebGL

    之前一直在捣鼓Vue和React栈,对组件化架构项目有了些理解和体会.今天尝尝WebGL,当然,并不打算现在深入,只是略作了解,我知道这个坑很深. js的图形库.3d库也有好几款比较流行的,如游戏开发 ...

  10. 如何在本地调试你的 Spark Job

    生产环境的 Spark Job 都是跑在集群上的,毕竟 Spark 为大数据而生,海量的数据处理必须依靠集群.但是在开发Spark的的时候,不可避免我们要在本地进行一些开发和测试工作,所以如何在本地用 ...