SpringBoot微信注文システム1:データベーステーブル設計

3789 ワード

プロジェクト設計
購入者、携帯端末販売者、PC端末
きのうぶんせき
バイヤー->商品の照会->注文の作成/キャンセル->売り手の支払い->注文の照会/キャンセル/受入->商品の管理->返金
導入アーキテクチャ
微信/ブラウザ->ng->tomcat->redis/mysql
データベース設計
1. product_info
注意点:
  • 自己増加タイプに上限があるため、自己増加タイプをプライマリキーとして使用することはできません.
  • 文字列の長さは一般的に2のn次方に設定され、これが整数である.
  • update_time timestamp not null default current_timestamp on update current_timestamp comment ' ' .なお、デフォルト現在時刻default current_timestamp,on update current_timestampは、変更時に自動的に時刻を更新することができる.
  • データベースバージョン、sql文、select version();
  • を表示
  • 一般的に商品によってproduct_idが検索するのでproduct_idはメインキーとします.

  • 完全なテーブル文:
    create table wxorder_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_desciption` 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 '   ';
    

    2. product_info
    注意点:
  • なぜidをクラス番号として使わないのか、クラス番号のため...(よくわかりません)
  • クラス番号は一意なので、制約インデックスを追加します.
  • create table `wxorder_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 '   ';
    

    3. order_master
    create table `wxorder_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 key_buyer_openid (`buyer_openid`)
    )comment '   ';
    

    4. wxorder_order_detail
    create table `wxorder_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`),
        index `idx_order_id` (`order_id`)
    ) comment '    ';
    

    5. wxorder_order_master