[SQL ] 請教多型多對多 外鍵建置

看板Database作者 (nothing)時間10年前 (2015/07/29 17:30), 10年前編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
資料庫名稱:MariaDB 資料庫版本:5.5 內容/問題描述 : 小弟因需求面的關係,設計多對多的table 假設有4個tables object table mapping table car table computer table object table定義各種物件的共同性質,如體積 重量等, car table則定義汽車的性質,如車門數 品牌等, computer table定義電腦的各種特性,如CPU速度 記憶體大小等. mapping table則是對應object與car/computer. (所以有4個欄位 1.流水號 2.object的主鍵 3.car或computer的主鍵 4.記錄該筆資料要對應car還是computer,假設用enum data type) ex:object A 透過mapping可以得知會對應到car a object B 則對應到computer b object 和 mapping之間的外件很明確. 但mapping和car/computer之間的外鍵要如何建立?? 感謝各位! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.70.205 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1438162252.A.7D0.html ※ 編輯: abcg5 (125.227.70.205), 07/29/2015 17:31:59

07/29 17:40, , 1F
是否能在建外鍵時設定enum欄為該等於什麼? 試不出來Orz
07/29 17:40, 1F
文章代碼(AID): #1Lk9rCVG (Database)