Topic: Product model with a twist of join tables
I'm learning Rails to try and build a humble website for our products with some basic e-commerce functionality. I've got very limited experience with designing databases up fom scratch and was hoping someone could give me some pointers on how to improve my structure.
We sell design furniture and each product can have many options, and it can also have many modules (such as a multi-piece sofa). To be compatible with the tutorials I have on e-commerce I've connected these three different types of stuff in one table, items (which also holds default price).
An item (either product, module or option) can have many styles (a combination of material, color and finish) and a style can also have many products. I always need to track if there is a priceincrease from selecting another style and sometimes need to track which component (i.e. a leg or seat) each style is applicable to.
I also need a way to connect items with pictures, which can sometimes hold many products. It is also necessary to register which style (and sometimes which component-style combo) is in the picture.
This is my proposed structure for modeling our products:
I somehow get the feeling that it's not very optimized and I was hoping that someone might have some input on how to improve the structure. These are my own thoughts on the matter:
* I get the feeling that my item-table might be a bit overkill, maybe I should go for registering modules and options in the product-table instead and use a type/parent_id-reference instead (similar to what has_attachment does with thumbnails).
* Perhaps I can merge the Inspiration_Pictures and Item_Pictures into one table, since I'm going to do the same stuff with them in terms of resizing etc. ?
* Maybe I should split up my Items_Styles-join table and not clutter up the join-table with extra info?
I appreciate any input! (even if it's about mistakes in my modeling-diagram hahaha...)
Last edited by Gustav (2007-03-20 10:13:51)