mendoz Posted May 6, 2008 Share Posted May 6, 2008 Hey guys. I don't know if the title is correct but here is the situation. Some of my database: products categories id id parent_id parent_id name name All going well so far. Now I would like each product to have extra data depending on the category. For example: products in 'Laptop' category would have data like 'battery_time', 'memory', 'cpu' etc. I'd like the user to be able to edit different 'data sets' or whatever this is called. For example: user wants to add fields 'color' and 'year' to the extra data template for category 'guitar'. How can I represent the this in mysql? I hope you could understant my question... If not tell me please. Thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted May 6, 2008 Share Posted May 6, 2008 Another table.... Quote Link to comment Share on other sites More sharing options...
mendoz Posted May 6, 2008 Author Share Posted May 6, 2008 Yeah, I know it's gonna take a table or two or three. But how? Quote Link to comment Share on other sites More sharing options...
smartin1017 Posted May 6, 2008 Share Posted May 6, 2008 You would probably have to set up some sort of CMS so that the different rows or columns are displayed in an editable field, such as textboxes. There would have to be an option there for them to ad field, it doesnt matter what it looks like on the outside its the coding on the backend that will take the information and create a field or what not. Be very leary of this route though because you would be opening up your database to people entering info which could lead to problems. Make sure you look in to keeping it secure and I would do some sort of login page. Quote Link to comment Share on other sites More sharing options...
mendoz Posted May 6, 2008 Author Share Posted May 6, 2008 Thanks for your comment smartin. You got my request wrong, I already have an idea of how the front-end should be like. I'm just asking for an idea on what tables do I have to create to store this dynamic data. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 7, 2008 Share Posted May 7, 2008 Yeah, I know it's gonna take a table or two or three. But how? Since it doesn't sound like the details are shared, make tables called guitar_detail, laptop_detail, etc., corresponding to your category name. Quote Link to comment Share on other sites More sharing options...
mendoz Posted May 7, 2008 Author Share Posted May 7, 2008 Yeah, but I want different templates . Maybe all categories will show ('name','year','weight','height'), Except for two categories which will show ('name','year','color','temperature'); So I would need two templates. What I did so far: templates_table: template_id template_name templates_cell_table: cell_id template_id cell_name products categories data_templates templates_cells id id id id parent_id parent_id name template_id name name text [/td] [td]template_id Now it is easy to select a template and to get it's cells. But what about the data for each product? Quote Link to comment Share on other sites More sharing options...
fenway Posted May 7, 2008 Share Posted May 7, 2008 I don't know what you mean by "cell", "data", and "template". But I would still do one each. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.