数据库设计

数据库表之间的关系

    • 类目表(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. pytest文档33-Hooks函数获取用例执行结果(pytest_runtest_makereport)

    前言 pytest提供的很多钩子(Hooks)方法方便我们对测试用例框架进行二次开发,可以根据自己的需求进行改造. 先学习下pytest_runtest_makereport这个钩子方法,可以更清晰的 ...

  2. CentOS 7操作系统目录结构介绍

    CentOS 7操作系统目录结构介绍 操作系统存在着大量的数据文件信息,相应文件信息会存在于系统相应目录中,为了更好的管理数据信息,会将系统进行一些目录规划,不同目录存放不同的资源. 根下目录结构说明 ...

  3. 【状态压缩DP】SCOI2009 围豆豆

    题目大意 洛谷链接 在一个\(N×M\)的矩阵方格内分布着\(D\)颗豆子,每颗豆有不同的分值\(V_i\).游戏者可以选择任意一个方格作为起始格,每次移动可以随意的走到相邻的四个格子,直到最终又回到 ...

  4. centos8平台使用ab做压力测试

    一,安装ab [root@blog ~]# yum install httpd-tools 说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/archi ...

  5. oracle统计同一字段0和1

    SELECT 班级表.班级编号,班级表.班级名称,SUM(DECODE(性别, '1', 1)) 女生人数,SUM(DECODE(性别, '0', 1)) 男生人数FROM 学生表, 班级表WHERE ...

  6. DateDiff() 方法语法 T-SQL语法

    表达式DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]]) 允许数据类型: timeinterval 表示 ...

  7. 【Azure Redis 缓存 Azure Cache For Redis】如何设置让Azure Redis中的RDB文件暂留更久(如7天)

    问题描述 Azure Redis和所有的Redis服务一样,可以让你保留存储在Redis中的数据.以防万一在Redis服务器出现故障的时候能尽可能小的减少数据的损失.在Azure Redis服务中,默 ...

  8. 联赛模拟测试22 D. 简单计算

    题目描述 分析 \(\sum_{i=0}^p[(p|qi)?0:1]=\sum_{i=0}^p[(p/gcd(p,q)|qi/gcd(p,q))?0:1]=\sum_{i=0}^p[(p/gcd(p, ...

  9. 关于 Deployer 部署结构

    Deployer 部署完成后,在服务器上的结构会是这样子: drwxr-sr-x 5 deployer www-data 4096 Jun 14 09:53 ./ drwxr-sr-x 6 deplo ...

  10. Layui treeSelect 回写与对应选中

    今天遇到个问题就是Layui treeSelect 的回写与特定选中,网络上居然没啥资料,有的也是不全的,于是花了点时间处理好了,这里写一下,方便以后有遇到的朋友借鉴. 一.父页面 二.Form编辑框 ...