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 '卖家信息表';  
    

      

      

  • 相关阅读:
    kafka关于修改副本数和分区的数的案例实战(也可用作leader节点均衡案例)
    kafka集群监控之kafka-manager部署(kafka-manager的进程为:ProdServerStart)
    flume配置kafka channle的实战案例
    HTML&CSS基础-表格简介
    HTML&CSS基础-雪碧图的制作和使用
    Hadoop生态圈-使用Ganglia监控flume中间件
    JavaScript基础知识-条件运算符(三元运算符)
    初识Apache Kafka 核心概念
    Hadoop生态圈-CentOs7.5单机部署ClickHouse
    安装Cloudera manager agent步骤详解
  • 原文地址:https://www.cnblogs.com/amoyzhu/p/8952752.html
Copyright © 2011-2022 走看看