Jump to content

Idea on how to represent data?


mendoz

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.