zoukankan      html  css  js  c++  java
  • 微信点餐数据库表设计

    -- 微信点餐数据库表设计
    -- product_info商品表
    -- product_category类目表
    -- order_master订单主表
    -- order_detail订单详情表
    -- seller_info卖家信息表

    -- 商品表
    -- 主键:product_id
    -- 创建时间:默认当前时间default current_timestamp
    -- 修改时间:每次修改数据时,数据库自动修改为当前时间on update current_timestamp
    create table product_info (
    	product_id varchar(32) not null,
    	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 '修改时间',
    	primary key(product_id)
    )comment '商品表';
    
    
    -- 类目表
    --  主键:category_id
    --  约束索引:查询商品表product_info时,会通过类目编号category_type来查,因此类目编号是唯一的,不能出现两个相同的类目编号
    
    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 '修改时间',
    	primary key(category_id),
    	unique key uqe_category_type (category_type)
    )comment '类目表';
    
    -- 订单表
    --  主键:查询订单详情表order_detail时,会通过order_id来查订单表,所以要定义主键
    --  索引:查询卖家下了哪些订单seller_info时,要用buyer_openid来查
    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 '修改时间',
    	primary key(order_id),
    	key idx_buyer_openid(buyer_openid)
    )comment '订单表';
    
    
    
    --  订单详情表
    --  主键:查询订单详情表order_detail,需要通过detail_id来表
    --  索引:查询订单表时,会通过order_id来查
    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 '修改时间',  
        primary key (detail_id),  
        key idx_order_id (order_id)  
    )comment '订单详情表';
    
      
    -- 卖家(登录后台使用, 卖家登录之后可能直接采用微信扫码登录,不使用账号密码)  
    create table seller_info (  
        id varchar(32) not null,  
        username varchar(32) not null,  
        password varchar(32) not null,  
        openid varchar(64) not null comment '微信openid',  
        create_time timestamp not null default current_timestamp comment '创建时间',  
        update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间',  
        primary key (id)  
    ) comment '卖家信息表';  
    

      

      

  • 相关阅读:
    paip.提升用户体验论文本编辑器的色彩方案
    paip.c++ qt 项目工程互相引用的方法
    paip.提升用户体验=c++ qt 字体切换功能缺少的总结..
    paip.提升用户体验自定义<<移位操作符重载
    paip.提升用户体验c++ gcc 命令语法着色搭配方案
    paip.c++ 指针跟引用的区别.
    paip.c++ qt 目录遍历以及文件操作
    paip. c++ 调用.net dll 最好方式powershell 使用总结.
    paip.提升用户体验c++ 源码字体自定义制造总结
    paip.提升用户体验c++ Qt5 实现程序图标以及动态托盘闪烁图标
  • 原文地址:https://www.cnblogs.com/amoyzhu/p/8952752.html
Copyright © 2011-2022 走看看