A car can have many attributes. Which scenario is better?
Store in a relational table
or just store an array in the car table like this:Code:=============================== car_table =============================== c_id | car_name ------------------------------- 1 | corvette 2 | civic =============================== attribute_table =============================== a_id | car_name ------------------------------- 1 | fast 2 | efficient 3 | stick 4 | automatic 5 | red 6 | silver car_attributes =============================== c_id | a_id ------------------------------- 1 | 1 1 | 3 1 | 5 2 | 2 2 | 4 2 | 6
Code:========================================================== car_table ========================================================== c_id | car_name | attribute ---------------------------------------------------------- 1 | corvette | array(1,3,5) 2 | civic | array(2,4,6)
Scenario 1 would have more complex table joins, but would establish the ground rules using the table's naming conventions. Scenario 2 seems like the better option because it is easier to read and write to and rely s on the programming language to do the heavy lifting. For example, to read the array's stored, I would have to use a script function to determine what array=1 is and give it a value beforehand using a script. Where the first scenario, I would just pull the value from the table for array=1.
Thoughts?




Bookmarks