20170417_jeffrey - silenceuncrio/diary GitHub Wiki

0910

review

0925

engineering notebook

0940

今天先把 GPS WEB UI 完成再來做 monkeyjj 的事情

首先要能依據 make menuconfig 產生出來的 macro PROSRC_GNSS 被定義與否來決定網頁是否要顯示該功能

先實作該功能再來想辦法從 proscend/prosrc/www/Makefile 來連動該功能

1310

繼續 monkeyjj 的資料庫分析

進行 Step 3: Create simplified Entity-Relationship diagram 之前

我需要把上禮拜 Step 1Step 2 的結果寫成英文

step 1: Discover entities and assign attributes

客人 商品 貨源 架(團購貨架)
臉書帳號 名稱 貨源名稱 團購名稱 下單日期
email 成本售價 網址 上架時間

用英文再寫一次 順便補一下 attribute

Customers Commodities CommoditySources CommodityShelves Orders
(PK) CustomerId (PK) CommodityId (PK) CommoditySourceId (PK) CommodityShelveId (PK) OrderId
Name Name SourceName ShelveName DatePlaced
FBAccount Cost DateStarted TotalPrice
Email Price DateEnded
Description

1335

Step 2: Derive unary and binary relationships

客人 商品 貨源 架(團購貨架)
客人 - - - -
商品 - - -
貨源 包含 - -
團購貨架 -
包含

用英文再寫一次 順便補一下 attribute

Customers Commodities CommoditySources CommodityShelves Orders
Customers - - - -
Commodities - - -
CommoditySources supply - -
CommodityShelves hit -
Orders place has

1345

進行 Step 3: Create simplified Entity-Relationship diagram

利用 draw.io 來畫圖

image

1425

先把 GPS 網頁時做的部分 上 code

1435

進行 Step 4: List assertions for all relationships

參考 Step 2: Derive unary and binary relationships

Customers Commodities CommoditySources CommodityShelves Orders
Customers - - - -
Commodities - - -
CommoditySources supply - -
CommodityShelves hit -
Orders place has

從 row 開始寫

  • A Customer can place many orders
  • A Commodity must be supplied from only one CommoditySource
  • A Commodity can hit many CommodityShelve
  • A Commodity can be contained in many orders

反過來描述

  • A order must be placed by only one Customer
  • A CommoditySource must supply at least one Commodity
  • A CommodityShelve must be hit by at least one Commodity
  • A order must have at least one Commodity

反覆檢查一下符不符合目前的情況

覺得 Commodity(商品) 的 Price(售價) 應該是跟著每次的開團而決定

看來要從頭來一次了

1525

回到 Step 1-1: Discover the entities

之前的 entities 有

  • 客人
  • 商品
  • 貨源
  • 架(團購貨架)

目前再次思考過的 entities 有

  • 團主
  • 團購團
  • 客人
  • 團購商品
  • 商品
  • 貨源

先跳過 Step 1-2 直接整理 Step 2: Derive unary and binary relationships 所需要的 Matrix

團主 團購團 客人 團購商品 商品 貨源 團購單
團主
團購團 開團
客人
團購商品 包含
商品 屬於 入團
貨源 供應
團購單 下單 包含

直接進行 Step 4: List assertions for all relationships 的分析

  • 團主 can 開團 many 團購團
  • 團主 can 擁有 many 商品
  • 團購團 must 包含 at least one 團購商品
  • 客人 can 下單 many 團購單
  • 團購商品 must be 入團ed by only one 商品
  • 團購商品 must be 包含ed in only one 團購團
  • 商品 must be 供應ed by only one 貨源

反過來看看

  • 團購團 must be 開團 by only one 團主
  • 商品 must be 擁有 by only one 團主
  • 團購商品 must be 包含ed in only one 團購團
  • 團購單 must be 下單 by only one 客人
  • 商品 can 入團 成為 only one 團購商品
  • 團購團 must 包含 at least one 團購商品
  • 貨源 must 供應 at least one 商品

仔細 review 一下

1625

Step 2: Derive unary and binary relationshipsMatrix 轉成 英文

Owners GroupBuyings Buyers GroupBuyingProducts Products ProductSupplier GroupBuyingOrders
Owners
GroupBuyings create
Buyers
GroupBuyingProducts contain
Products own join
ProductSupplier supply
GroupBuyingOrders place fill

再做一次 Step 4: List assertions for all relationships

  • A Owner can create many GroupBuyings
  • A Owner can own many Products
  • A GroupBuying must contain at least one GroupBuyingProducts
  • A Buyer can place many GroupBuyingOrders
  • A GroupBuyingProduct must be joined by only one Product
  • A GroupBuyingProduct must fill into only one ...

覺得可以把 GroupBuyingProduct 這個 entity 刪掉

再重新整理一下 Step 2: Derive unary and binary relationships

Owners GroupBuyings Buyers Products ProductSuppliers GroupBuyingOrders
Owners
GroupBuyings create
Buyers
Products own join
ProductSuppliers supply
GroupBuyingOrders place fill

再做一次 Step 4: List assertions for all relationships

  • A Owner can create many GroupBuyings
  • A Owner can own many Products
  • A GroupBuying must be joined by at least one Product
  • A Buyer can place many GroupBuyingOrders
  • A Product must be supply by only one ProductSupplier
  • A Product can fill into many GroupBuyingOrders

反過來

  • A GroupBuyings must be created by only one Owner
  • A Product must be owned by only one Owner
  • A Product can join many GroupBuying
  • A GroupBuyingOrders must be placed by only one Buyer
  • A ProductSupplier must supply at lease one Products
  • A GroupBuyingOrders must be filled by at least one Product

順多了

Step 1-2: Assign attributes to each entity discovered

  • Owners
    • Name
    • Email
  • GroupBuyings
    • Name
    • Description
    • DateStarted
    • DateEnded
  • Buyers
    • Name
    • Email
    • FBAccount
  • Products
    • Name
    • Cost
  • ProductSupplier
    • Name
    • URL
  • GroupBuyingOrders
    • DatePlaces
    • TotalCost

Step 1-3: Select identifiers, keys and primary keys from attributes for each entity

  • Owners
    • (PK) OwnerId
    • Name
    • Email
  • GroupBuyings
    • (PK) GroupBuyingId
    • Name
    • Description
    • DateStarted
    • DateEnded
  • Buyers
    • (PK) BuyerId
    • Name
    • Email
    • FBAccount
  • Products
    • (PK) ProductId
    • Name
    • Cost
  • ProductSuppliers
    • (PK) ProductSupplierId
    • Name
    • URL
  • GroupBuyingOrders
    • (PK) GroupBuyingOrderId
    • DatePlaces
    • TotalCost

1725

再來一次 Step 3: Create simplified Entity-Relationship diagram

image

感覺 GroupBuyingOrders 不應該跟 Products 有關係

而是等 GroupBuyingsProducts 產生關係後的那個 關係 才會跟 GroupBuyingOrders 有某種關係

我先把 GroupBuyingOrdersProducts 之間的關係拿掉好了

重新整理一下 Step 2: Derive unary and binary relationships

Owners GroupBuyings Buyers Products ProductSuppliers GroupBuyingOrders
Owners
GroupBuyings create
Buyers
Products own join
ProductSuppliers supply
GroupBuyingOrders place

再一次 Step 3: Create simplified Entity-Relationship diagram

image