資料庫設計

2021-10-06 20:01:29 字數 4153 閱讀 9906

一、商品表

create

table goods (

id bigint(20

)not

null

auto_increment

comment

'商品id'

, goods_name varchar(16

)default

null

comment

'商品名稱'

, goods_title varchar(64

)default

null

comment

'商品標題'

, goods_img varchar(64

)default

null

comment

'商品的'

, goods_detail longtext

comment

'商品的詳情介紹'

, goods_price decimal(10

,2)default

'0.00'

comment

'商品單價'

, goods_stock int(11

)default

'0'comment

'商品庫存,-1表示沒有限制'

,primary

key(id)

)engine

=innodb

auto_increment=3

default

charset

=utf8mb4;

插入兩條語句

insert

into goods values(1

,'iphonex',,

'/img/iphonex.png',,

8765.00

,10000),

(2,'華為meta9'

,'華為meta9 4gb+32gb 月光銀 移動聯通電信4g手機 雙卡雙待'

,'/img/meta9.png'

,'華為meta9 4gb+32gb 月光銀 移動聯通電信4g手機 雙卡雙待'

,3212.00,-

1);

二、秒殺商品表

create

table

`miaosha_goods`

(`id`

bigint(20

)not

null

auto_increment

comment

'秒殺的商品表'

,`goods_id`

bigint(20

)default

null

comment

'商品id'

,`miaosha_price`

decimal(10

,2)default

'0.00'

comment

'秒殺價'

,`stock_count`

int(11)

default

null

comment

'庫存數量'

,`start_date`

datetime

default

null

comment

'秒殺開始時間'

,`end_date`

datetime

default

null

comment

'秒殺結束時間'

,primary

key(

`id`))

engine

=innodb

auto_increment=5

default

charset

=utf8mb4;

插入兩條語句

insert

into miaosha_goods values(1

,1,0.01,4

,'2017-11-05 15:18:00'

,'2017-11-13 14:00:18'),

(2,2

,0.01,9

,'2017-11-12 14:00:14'

,'2017-11-13 14:00:24'

);

三、訂單表

create

table

`order_info`

(`id`

bigint(20

)not

null

auto_increment

,`user_id`

bigint(20

)default

null

comment

'使用者id'

,`goods_id`

bigint(20

)default

null

comment

'商品id'

,`delivery_addr_id`

bigint(20

)default

null

comment

'收穫位址id'

,`goods_name`

varchar(16

)default

null

comment

'冗餘過來的商品名稱'

,`goods_count`

int(11)

default

'0'comment

'商品數量'

,`goods_price`

decimal(10

,2)default

'0.00'

comment

'商品單價'

,`order_channel`

tinyint(4

)default

'0'comment

'1pc,2android,3ios',`

status

`tinyint(4

)default

'0'comment

'訂單狀態,0新建未支付,1已支付,2已發貨,3已收貨,4已退款,5已完成'

,`create_date`

datetime

default

null

comment

'訂單的建立時間'

,`pay_date`

datetime

default

null

comment

'支付時間'

,primary

key(

`id`))

engine

=innodb

auto_increment

=1565

default

charset

=utf8mb4;

四、秒殺訂單表

create

table

`miaosha_order`

(`id`

bigint(20

)not

null

auto_increment

,`user_id`

bigint(20

)default

null

comment

'使用者id'

,`order_id`

bigint(20

)default

null

comment

'訂單id'

,`goods_id`

bigint(20

)default

null

comment

'商品id'

,primary

key(

`id`),

unique

key`u_uid_gid`

(`user_id`

,`goods_id`

)using

btree

)engine

=innodb

auto_increment

=1551

default

charset

=utf8mb4;

資料庫設計 設計資料庫之前

1.考察現有環境 在設計乙個新資料庫時,你不但應該仔細研究業務需求而且還要考察現有的系統。大多數資料庫 專案都不是從頭開始建立的 通常,機構內總會存在用來滿足特定需求的現有系統 可能沒有實 現自動計算 顯然,現有系統並不完美,否則你就不必再建立新系統了。但是對舊系統的研究 可以讓你發現一些可能會忽略...

資料庫設計 設計資料庫之前

1.考察現有環境 在設計乙個新資料庫時,你不但應該仔細研究業務需求而且還要考察現有的系統。大多數資料庫 專案都不是從頭開始建立的 通常,機構內總會存在用來滿足特定需求的現有系統 可能沒有實 現自動計算 顯然,現有系統並不完美,否則你就不必再建立新系統了。但是對舊系統的研究 可以讓你發現一些可能會忽略...

資料庫設計 設計資料庫之前

1.考察現有環境 在設計乙個新資料庫時,你不但應該仔細研究業務需求而且還要考察現有的系統。大多數資料庫 專案都不是從頭開始建立的 通常,機構內總會存在用來滿足特定需求的現有系統 可能沒有實 現自動計算 顯然,現有系統並不完美,否則你就不必再建立新系統了。但是對舊系統的研究 可以讓你發現一些可能會忽略...