(一)廖師兄springboot微信點餐SQL建表腳本


 

數據庫設計

數據庫表之間的關系

    • 類目表(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 '訂單詳情表';

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM