###### tags: `Reports` # Report 2: [toc] ## E-R diagram設計圖 ![](https://i.imgur.com/TfScG1v.png) ## 設計圖說明 ### Entity Set ## 1. User = (**id**, username, password) #### Attribute * id: primary key * username: 使用者姓名 * password: 使用者密碼 #### 概念/限制 存取使用者的資訊,每位使用者都能當post商品者與出價者 ## 2. Product = (**id**, name, description, category, image, start_time, end_time, start_price, current_price) #### Attribute * id: primary key * name: 商品名稱 * description: 商品敘述 * category: 商品類別 * image: 商品圖示 * start_time: 競標起始時間 * end_time: 競標結束時間 * start_price: 競標底價 * current_price: 目前競標價錢 #### 概念/限制 存取商品的資訊,與相關的競標時間、價錢等 ## 3. Bid_record = (**date_time**, bid_price) #### Attribute * date_time: 下標時間 primary key * bid_price: 下標價錢 #### 概念/限制 此為一個weak entity set 依附於 Product ### Relationship set User 與 Product 之間的relation ## 1. post_item = (datetime) #### Attribute * date_time: post商品的時間 #### 概念/限制 使用者post的競標商品,User與Product的關係為one to many,並且Product端為total partition ## 2. watchlist #### 概念/限制 使用者的商品觀看名單,User與Product的關係為many to many,兩端皆為partial partition ## 3. comments = (date_time, comment) #### Attribute * date_time: 留言的時間 * comment: 留言的內容 #### 概念/限制 使用者於某個商品下的留言,User與Product的關係為many to many,兩端皆為partial partition ## 4. winner #### 概念/限制 使用者得標的商品,User與Product的關係為one to many,兩端皆為partial partition ## 5. bid_final = (date_time, is_notified) #### Attribute * date_time: 通知的時間 * is_notified: 使用者是否看到通知 #### 概念/限制 通知曾經出價的使用者有新的出價,User與Product的關係為many to many,兩端皆為partial partition ## 6. bid_list #### 概念/限制 儲存所有出價紀錄的商品,Bid_record與Product的關係為many to one,Bid_record端為total partition,Product端為partial partition ## 7. bid_by #### 概念/限制 儲存所有出價紀錄的出價者,User與Bid_record的關係為one to many,Bid_record端為total partition,User端為partial partition ## 不同設計的可能性 ### Own list(得標列表) 兩種設計 1. 在使用者下標並得標之後,增加新的資料於user 跟 product 的 relation **own** ![](https://i.imgur.com/ihn68rX.png) 3. 從已經存在的bid_list relation抓取資料 最後選擇第一種設計方式,因為第二種設計方式要下的query較複雜,且在資料過多的情況下,會耗用較多時間在query ### Category(物品分類) 兩種設計 1. 合併到product 裡面當attribute ![](https://i.imgur.com/1JeDusv.png) 3. 自己獨立一個entity set ![](https://i.imgur.com/7TJKWsV.png) 最後選擇第一種設計方式,由於project 設計category的數量為固定的,所以直接給定使用者不同的category做選擇,而第二種設計方式可能對於使用者也能增加category比較合適 ### Time(下標時間) 兩種設計 1. 合併到product 裡面當attribute ![](https://i.imgur.com/nZbtQ2M.png) 3. 自己獨立一個 依附於Product 的weak entity set 最後選擇第一種設計方式,由於time 雖然會持續增加且不重複,但只有product會用到這個attribute,額外獨立成一個weak entity set沒有太大意義,故最後決定合併進product ### FeedBack ![](https://i.imgur.com/HBnVgHI.png)