數據庫表 概要設計


vc 端符合直覺,m 端追求快速(TDD BDD) 長期...

 

【縮寫】

我們規定 類似 bq = blockquote

cT = create_time  

uT = update_time

id = ${entity}_id

 

【約定大於配置】 create_time update_time 是沒有打日志情況最后一根稻草

`create_time` timestamp not null default current_timestamp comment '創建時間',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改時間',

 

【概要設計規定】

1. constraint 約束先忽略    not null    自增 auto_increment

2. 類型先忽略  int varchar timestamp 

3. 數據字典 先忽略 comment

4. 默認值 DEFAULT 先忽略

5. 違反第三范式 適當數據冗余減少join (遵守第一范式二維表 第二范式 context + 主鍵) 

  

【Java 幾種實體】就是說我們不用外鍵,讓程序去維護幾個實體的關聯。

DTO (data2obj 作為傳輸實體存在) = (Entity1 + Entity2)(service 業務驅動) 

XXXForm (表單實體) = 前端表單參數封裝( API 驅動 )

VO (作為規定格式實體返回給前端而存在)

 

【幾個 Key】Refs

primary key 

foreign key 外鍵 第三范式 

unique key 插入數據不重復 

  => 考慮分布式場景 使用mysql自帶約束限制唯一性,如 UNIQUE KEY `user_name_unique` (`username`) USING BTREE

key 邏輯層加快查詢速度 另外不建議 強制索引

  index 物理層

 

實體表

【product_category】 (id,category_name,catagory_type)  & pk(id)

【product_info】(id,product_name,product_price,product_stock,

  product_description,product_icon,product_status,category_type) & pk(id)

【order_master】(id,buyer_name,buyer_phone,buyer_address,buyer_openid,

  order_status,pay_status) & pk(id) & key(buyer_openid)

【order_detail】(detail_id,order_id,product_id,product_name,product_price,

  product_quantity,product_icon)&pk(detail_id)&key(order_id)

【seller_info】(id,username,password,openid) & pk(id)

…………………………………………………………………………………………………………

特殊的表

分類表 【遞歸層級】

 

類型

 datetime 較方便查看創建時間 更新時間

 text 富文本

 decimal(totaLen,preci)

 


免責聲明!

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



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