数据库设计

数据库表之间的关系

    • 类目表(product_category)
    • 商品表(product_info)
    • 订单主表(order_master)
    • 订单详情表(order_detail)
    • 卖家信息表(order_detail)

       
 
create table `product_info`(
`product_id` varchar(32) not null, --企业级的用varchar,自己玩的项目可以用自增的但数量大了可能不够用
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '单价',
`product_stock` int not null comment '库存',
`product_description` varchar(64) comment '描述',
`product_icon` varchar(512) comment '小图',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', --MYSQL5.7才可以default current_timestamp
primary key (`product_id`)
) comment '商品表';

create table `product_category`(
`category_id` int not null auto_increment, -- 类目不太可能爆多,所以可以自增
`category_name` varchar(64) not null comment '类目名字',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', --MYSQL5.7才可以default current_timestamp
primary key (`category_id`)
unique key `uqe_category_type` (`category_type`) --类目是唯一的
) comment '类目表'

create table `order_master`(
`order_id` varchar(32) not null,
`buyer_name` varchar(32) not null comment '买家名字',
`buyer_phone` varchar(32) not null comment '买家电话',
`buyer_address` varchar(128) not null comment '买家地址',
`buyer_openid` varchar(64) not null comment '买家微信openid',
`order_amount` decimal(8,2) not null comment '订单总金额',
`order_status` tinyint(3) not null default '0' comment '订单状态,默认0新下单',
`pay_status` tinyint(3) not null default '0' comment '支付状态,默认0未支付',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', --MYSQL5.7才可以default current_timestamp
primary key (`order_id`),
key `idx_buyer_openid` (`buyer_openid`)
) comment '订单表';

create table `order_detail`(
`detail_id` varchar(32) not null,
`order_id` varchar(32) not null,
`product_id` varchar(32) not null,
`product_name` varchar(64) not null comment '商品名字',
`product_price` decimal(8,2) not null comment '商品价格',
`product_quantity` int not null comment '商品数量',
`product_icon` varchar(512) comment '商品小图',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新时间', --MYSQL5.7才可以default current_timestamp
primary key (`detail_id`),
key `idx_order_id`(`order_id`)
) comment '订单详情表';

(一)廖师兄springboot微信点餐SQL建表脚本的更多相关文章

  1. 廖师兄springboot微信点餐开发中相关注解使用解释

    package com.imooc.dataobject;import lombok.Data;import org.hibernate.annotations.DynamicUpdate;impor ...

  2. (二)廖师兄springboot微信点餐虚拟机说明文档

    虚拟机 VirtualBox-5.1.22  系统 CentOS7.3账号 root密码 123456 软件:jdk 1.8.0_111nginx 1.11.7mysql 5.7.17redis 3. ...

  3. SQL SERVER 生成建表脚本

    /****** Object: StoredProcedure [dbo].[GET_TableScript_MSSQL] Script Date: 06/15/2012 11:59:00 ***** ...

  4. SQL SERVER 生成MYSQL建表脚本

    /****** Object: StoredProcedure [dbo].[GET_TableScript_MYSQL] Script Date: 06/15/2012 13:05:14 ***** ...

  5. SQL SERVER 生成ORACLE建表脚本

    /****** Object: StoredProcedure [dbo].[GET_TableScript_ORACLE] Script Date: 06/15/2012 13:07:16 **** ...

  6. (转)SQL SERVER 生成建表脚本

    https://www.cnblogs.com/champaign/p/3492510.html /****** Object: StoredProcedure [dbo].[GET_TableScr ...

  7. SQL创建表脚本

    <1>SQL Server设置主键自增长列 SQL Server设置主键自增长列   1.新建一数据表,里面有字段id,将id设为为主键   www.2cto.com   create t ...

  8. spark sql建表的异常

    在使用spark sql创建表的时候提示如下错误: missing EOF at 'from' near ')' 可以看下你的建表语句中是不是create external table ....   ...

  9. sql建表,建索引注意事项

    建表注意 .建议字段定义为NOT NULL 搜索引擎 MyISAM InnoDB 区别 InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定.基 ...

随机推荐

  1. 在Linux终端中快速生成、解码二维码

    我们要实现两个功能: 解码Linux屏幕上的二维码,将结果输出在终端 在终端中将字符串转为二维码,直接显示二维码在终端中以供扫描 实现方法 生成二维码 qrencode是一个常见的生成二维码的CLI程 ...

  2. zookeeper动态添加/删除集群中实例(zookeeper 3.6)

    一,用来作为demo操作的zookeeper集群中的实例: 机器名:zk1 server.1=172.18.1.1:2888:3888 机器名:zk2 server.2=172.18.1.2:2888 ...

  3. html的keywords标签

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /& ...

  4. py正则表达式(全是干货系列)

      正则表达式的作用在这里不多赘述了,反正处理文本任务贼六就对了.Python中的正则表达式是内置在re模块中的,我们就对这个模块进行详细地讲解.这是一篇媲美帮助文档的文章!对就这么自信,不服你顺着网 ...

  5. Vue实例中封装api接口的思路 在页面中用async,await调用方法请求

    一般我们写小型的项目是用不到封装axios实例 但是当我们写大型项目时  接口有时候多到有上百个接口,那我们在请求一次调用一次接口,接口上好多都是重复的,这个时候我们就可以封装axios实例,既节省了 ...

  6. springboot添加拦截器

    一,编写拦截器 public class TokenInterceptor implements HandlerInterceptor { @Override public boolean preHa ...

  7. Graph-to-ID task

    首先图像是一个二维的结构,CNN提取图片的特征,但是是local的,通过kenel的形式,不断的图上移动,通过卷积的形式, 无论移动到哪个位置,内部的结构都是不变的,这就是参数共享. 这个所说的图像显 ...

  8. NMS总结

    目录 NMS总结 一. NMS 二. Soft-NMS 三. IOU-Guided NMS 四. Softer-NMS 五. DIOU-NMS 六. 总结 NMS总结 一. NMS 目标检测:同一个类 ...

  9. D. Alyona and Strings 解析(思維、DP)

    Codeforce 682 D. Alyona and Strings 解析(思維.DP) 今天我們來看看CF682D 題目連結 題目 略,請直接看原題. 前言 a @copyright petjel ...

  10. Gym102012A Rikka with Minimum Spanning Trees

    题意 \(T\) 组数据,每组数据给定一个 \(n\) 个点,\(m\) 条边,可能含有重边自环的图,求出最小生成树的个数与边权和的乘积,对 \(10^9+7\) 取模. \(\texttt{Data ...