Jump to content

[SOLVED] Store serialized data or create a separate table?


gamex

Recommended Posts

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?

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).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.