作者:
abcg5 (nothing)
2015-07-29 17:30:49資料庫名稱: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之間的外鍵要如何建立??
感謝各位!