数据库设计

数据库表之间的关系

    • 类目表(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学习(二)--setup.s

    执行过bootsect.s,加载了所有系统代码之后,开始向32位模式转变,为main函数的调用做准备,同样,附上图往下看 1 INITSEG = 0x9000 ! we move boot here ...

  2. jdk、eclipse和idea安装

    一.jdk下载与环境配置与IDEA 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-213315 ...

  3. 从零开始针对 .NET 应用的 DevOps 运营实践 - Jenkins & SonarQube 安装配置

    一.Overview 继续 DevOps 实施的相关内容,在上一篇的博客中,完成了对于工具链中使用到的软件所需的运行环境的配置,在这一篇的博客中,将聚焦于我们使用到的两个主要的软件:Jenkins 与 ...

  4. List<String>转换为实体类的属性【转】

    package model; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arr ...

  5. flutter_bloc使用解析---骚年,你还在手搭bloc吗!

    前言 首先,有很多的文章在说flutter bloc模式的应用,但是百分之八九十的文章都是在说,使用StreamController+StreamBuilder搭建bloc,提升性能的会加上Inher ...

  6. 面试官问:HashMap在并发情况下为什么造成死循环?一脸懵

    这个问题是在面试时常问的几个问题,一般在问这个问题之前会问Hashmap和HashTable的区别?面试者一般会回答:hashtable是线程安全的,hashmap是线程不安全的. 那么面试官就会紧接 ...

  7. C#之txt的数据写入

    一.背景 小伙伴们在使用C#开发时,可能需要将一些信息写入到txt,这里就给大家介绍几种常用的方法. 二.思路 2.1将由字符串组成的数组写入txt 此种方法不需要使用Flush和Close(). 如 ...

  8. oracle sql developer 启动java.exe设置错误

    1.找到oracle安装目录下的jdk,如:E:\app\Administrator\product\11.2.0\dbhome_1\jdk 2.找到oracle安装目录下的developer路径:E ...

  9. 并发编程——多线程计数的更优解:LongAdder原理分析

    前言 最近在学习ConcurrentHashMap的源码,发现它采用了一种比较独特的方式对map中的元素数量进行统计,自然是要好好研究一下其原理思想,同时也能更好地理解ConcurrentHashMa ...

  10. 前端小程序——js+canvas 给图片添加水印

    市场上各种各样的图片处理器有很多,那么作为程序员的我们是不是应该自己做一个呢?那就从加水印开始吧 html: <canvas id="shuiyinTest"> < ...