高性能可扩展mysql 笔记(五)商品实体、订单实体、DB规划

个人博客网: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,在表名钱增加库名前缀

用户数据库

商品数据库:

订单数据库

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
技术的变革,一定是思想先行,云原生是一种构建和运行应用程序的方法,是一套技术体系和方法论。云原生(CloudNative)是一个组合词,Cloud+Native。Cloud表示应用程序位于云中,而不是传统的数据中心;Native表示应用程序从设计之初即考虑到云的环境,原生为云而设计,在云上以最佳姿势运行,充分利用和发挥云平台的弹性+分布式优势。云原生概括为4个要点:DevOps+持续交付+微服务+容器。符合云原生架构的应用程序应该是:采用开源堆栈(K8S+Docker)进行容器化,基于微服务架构提高灵活性和可维护性,借助敏捷方法、DevOps支持持续迭代和运维自动化,利用云平台设施实现弹性伸缩、动态调度、优化资源利用率。要转向云原生应用需要以新的云原生方法开展工作,云原生包括很多方面:基础架构服务、虚拟化、容器化、容器编排、微服务。本课程凝聚老师多年经验,基于真实工业界电商业务讲解,涉及多种技术落地方案,涉及多语言的协调开发,让学员在实战中熟悉云原生开发的全流程,感受云原生带来的开发便利。目前对云原生的人才需求也非常的大,谁尽早掌握,谁就能抓住这个风口,实现收入的增长。 本课程将分为3个阶段: 第一阶段:会基于云原生实现电商系统的大部分核心服务,包括:用户服务,商品服务,商品类目服务,商品属性服务,品牌服务,订单服务,网关服务等等。 第二阶段:基于云原生完成整个项目的持续集成,持续交付、持续部署,完成整个项目的自动化上云等等。  第三阶段: 进一步完善和优化电商系统,加入大数据,智能AI等等。  本课程包含的技术: IDEA集成开发工具 SpringBootSpringCloud SpringCloud AlibabaDevops MavenJenkinsCI/CD 持续集成 持续交付GitDocker Kubertenes 分布式系统微服务注册中心与配置中心:Nacos分布式系统微服务流量防卫兵:Sentinel分布式系统微服务网关:Gateway分布式系统微服务负载均衡:Feign分布式系统微服务链路追踪:Sleuth,Zipkin分布式系统微服务端点监控:spring boot adminSpringSecurity和JWT(认证和授权)消息中间件解决方案(RabbitMQ)MySQL(数据库)  MyCat MySQL分布式集群解决方案 Lucene、Elasticsearch(搜索) Nginx(web服务器)多语言(Go语言 Python语言 Java语言)CORS实现跨域 Swagger2 文档生成工具 Quartz分布式任务调度 Zookeeper Ehcache Restful VUE+jQuery+Ajax+NodeJS VUE+Element-UIGo+Gin 、 TensorFlow、RNN 、LSTM、Django、Spark大数据相关技术等等 课程亮点: 1.与企业无缝对接、工业界真实业务场景 2.集后端+前台+测试+运维一体,全面掌握技术链 3.多语言Java+Go+Python协调开发,属于语言应用场景4.支持项目快速迭代和开发 5.使用微服务技术栈+前后端分离构建项目 6.云上的开发体系,打造新一代研发平台7.引入全新的设计理念  8.集成SpringCloud Alibaba实现统一整合方案 9 Kubernetes+Docker容器化部署和管理 10 Devops全自动化持续集成和持续交付、部署11.TensorFlow、RNN 、LSTM综合应用12.动态扩展,弹性自动伸缩13.高并发下的服务降级、限流实战 14.实现高并发请求和实现高可用架构解决方案 15.引入大数据技术16.引入人工智能技术17.全程代码实操,提供课程代码和资料
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值