我正在構建產品數據庫。每個產品都屬於一個類別。只能有子類別下的產品。每個產品都具有名稱,名稱,價格,寬度,高度,深度,重量等屬性。但是,有一些基於類別的自定義屬性!像energy_class,number_of_programs,sound_volume等!我正在談論這樣的事情:具有基於belongs_to型號的額外列的模型
Category
|
|--Category <- This Category have extra information about extra attributes for Products
| |
| |--Category
| |
| |--Product
| |
| |--Product
|
|--Category <- This Category have extra information about extra attributes for Products
|
|--Category
| |
| |--Product
| |
| |--Product
|
|--Category
|
|--Product
|
|--Product
我不知道如何建立它。我需要一個類別和產品的數據庫。但是,一個類別需要知道要添加到產品的額外屬性。所以也許我必須爲extra_attributes創建一個表格?然後在category和extra_attributes之間做一個has_many關聯?但是產品需要了解這種關聯!也許我正在思考一個完全錯誤的方向......!也許我應該製作不同的產品類型?我希望你能指導我!
然後我將所有屬性作爲列存儲在產品表中? – Alexander 2011-03-26 23:44:20