gamex Posted September 9, 2009 Share Posted September 9, 2009 Ill try to keep this short and sweet I am creating my own shopping cart. I have an order_header table, which stores the info about the whole order (billing/shipping info, totals, etc), and an order_details table which stores information about each item. Each item is very customizable, so I have two options: 1) In the order_details table, have a field called 'item_attributes' and store a serialized array of data in the following format: array["Item_Attribute"] = item_value or 2) Create an item_attributes table with the following fields: order_detail_id attribute value Right now, each item has about 6 attributes, but it is possible for them to have 20 or more in the future once our company expands. I do not believe we will ever have to run queries searching for certain attributes. Which one of the options above is recommended in this case? Link to comment https://forums.phpfreaks.com/topic/173674-solved-store-serialized-data-or-create-a-separate-table/ Share on other sites More sharing options...
RichardRotterdam Posted September 9, 2009 Share Posted September 9, 2009 I think your table names are a bit confusing but maybe that's just my opinion This is what I think you mean. You want to know if you should use the following tables: - Oders (which you name order_header) - Products (which you name order_details) - Product_attributes (which you name item attributes If a product/item can have a x number and type of attributes I would create the 3rd table. Cramming a formated string in one table field which you can later translate into an array is just a bad database design (even though both OSCommerce and Virtuemart do this). Link to comment https://forums.phpfreaks.com/topic/173674-solved-store-serialized-data-or-create-a-separate-table/#findComment-915511 Share on other sites More sharing options...
gamex Posted September 9, 2009 Author Share Posted September 9, 2009 Thanks for the info. The only reason I was worried was because it could be possible for an item to have 60+ attributes, even more. I was just trying to look at the big picture and imagine how many records this table could have. Link to comment https://forums.phpfreaks.com/topic/173674-solved-store-serialized-data-or-create-a-separate-table/#findComment-915572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.